Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: API & general documentation #8

Merged
merged 4 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ Token Price Oracle is simple oracle for tracking token prices on-chain.
In this repo is located the Typescript Client orchestrator used for
tracking, management and orchestration of the data.

![Token Price Oracle - SC - banner](./assets/general-diagram.png)

## Documentation πŸ“š
You'll find the API specification under `/docs/api` and you can also run
interactive Swagger client by running the project and going to the `/api-docs` route in your browser.
_Example: http://localhost:3001/api-docs_

The main site for documentation is located on the [link here](https://despotf.gitbook.io/token-price-oracle/).

## Running the project πŸš€
### Requirements βœ…
- On your computer
Expand Down Expand Up @@ -44,7 +53,7 @@ if you're trying to run the project using docker or your local setup
4. Run `docker-compose up`
5. That's it!
> [!NOTE]
> If you've pulled new code files you'll have to rebuild the Docker image using `docker-compose build --no-cache node_backend`
> If you've pulled new code files you'll have to rebuild the Docker image using `docker-compose build --no-cache token_price_oracle_orchestrator_ts`

#### Running locally
4. Run ```yarn``` to install the dependencies
Expand Down
Binary file added assets/general-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions docs/api/Token-Price-Oracle-Orchestrator.openapi_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"openapi": "3.0.3",
"info": {
"title": "Token-Price-Oracle-Orchestrator",
"description": "Token Price Oracle is simple oracle for tracking token prices on-chain.\n\nThis is the documentatino of the API endpoints used for consuming the collected data",
"version": "1.0.0",
"contact": {}
},
"servers": [
{
"url": "http://localhost"
}
],
"paths": {
"/api/v1/tickers": {
"get": {
"tags": [
"Tickers"
],
"summary": "Ticker List",
"description": "Returns list of on-chain and off-chain price data of all the tickers available in the storage",
"operationId": "tickerList",
"responses": {
"200": {
"description": ""
}
}
}
},
"/api/v1/tickers/{tickerSymbol}": {
"get": {
"tags": [
"Tickers"
],
"parameters": [
{
"name": "tickerSymbol",
"in": "path",
"description": "Ticker of the asset",
"required": true,
"schema": {
"type": "string"
}
}
],
"summary": "Ticker",
"description": "Returns on-chain and off-chain price data of a given ticker.",
"operationId": "ticker",
"responses": {
"200": {
"description": ""
}
}
}
},
"/api/v1/tickers/{tickerSymbol}/history": {
"get": {
"tags": [
"Tickers"
],
"summary": "Ticker Historical prices",
"description": "Returns the historical price data of a given ticker between the given Unix timestamps",
"operationId": "tickerHistoricalPrices",
"parameters": [
{
"name": "tickerSymbol",
"in": "path",
"description": "Ticker of the asset",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "from",
"in": "query",
"schema": {
"type": "string",
"example": "1702532251"
}
},
{
"name": "to",
"in": "query",
"schema": {
"type": "string",
"example": "1702632251"
}
}
],
"responses": {
"200": {
"description": ""
}
}
}
},
"/api/v1/reverts": {
"get": {
"tags": [
"Reverts"
],
"summary": "On-chain historical reverts",
"description": "Returns all of the reverts that happened on-chain (regardless of the sender) for the price updating action on the TokenPriceStorage contract.",
"operationId": "onChainHistoricalReverts",
"responses": {
"200": {
"description": ""
}
}
}
}
},
"tags": [
{
"name": "Tickers",
"description": "All ticker data"
},
{
"name": "Reverts",
"description": "Historical reverts data"
}
]
}
118 changes: 118 additions & 0 deletions docs/api/Token-Price-Oracle-Orchestrator.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"info": {
"_postman_id": "ba5c6c37-b93c-4d5b-8d4b-74bec4dd9dff",
"name": "Token-Price-Oracle-Orchestrator",
"description": "Token Price Oracle is simple oracle for tracking token prices on-chain.\n\nThis is the documentation of the API endpoints used for consuming the collected data",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "16309767"
},
"item": [
{
"name": "Ticker List",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:3001/api/v1/tickers",
"protocol": "http",
"host": [
"localhost"
],
"port": "3001",
"path": [
"api",
"v1",
"tickers"
]
},
"description": "Returns list of on-chain and off-chain price data of all the tickers available in the storage"
},
"response": []
},
{
"name": "Ticker",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:3001/api/v1/tickers/{{tickerSymbol}}",
"protocol": "http",
"host": [
"localhost"
],
"port": "3001",
"path": [
"api",
"v1",
"tickers",
"{{tickerSymbol}}"
]
},
"description": "Returns on-chain and off-chain price data of a given ticker."
},
"response": []
},
{
"name": "Ticker Historical prices",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:3001/api/v1/tickers/{{tickerSymbol}}/history?from=1702532251&to=1702632251",
"protocol": "http",
"host": [
"localhost"
],
"port": "3001",
"path": [
"api",
"v1",
"tickers",
"{{tickerSymbol}}",
"history"
],
"query": [
{
"key": "from",
"value": "1702532251"
},
{
"key": "to",
"value": "1702632251"
}
]
},
"description": "Returns the historical price data of a given ticker between the given Unix timestamps"
},
"response": []
},
{
"name": "On-chain historical reverts",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:3001/api/v1/reverts",
"protocol": "http",
"host": [
"localhost"
],
"port": "3001",
"path": [
"api",
"v1",
"reverts"
]
},
"description": "Returns all of the reverts that happened on-chain (regardless of the sender) for the price updating action on the TokenPriceStorage contract."
},
"response": []
}
],
"variable": [
{
"key": "tickerSymbol",
"value": "ETH"
}
]
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/node-cron": "^3.0.11",
"@types/swagger-ui-express": "^4.1.6",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"eslint": "^8.55.0",
Expand All @@ -35,6 +36,7 @@
"log4js": "^6.9.1",
"node-cron": "^3.0.3",
"redux": "^5.0.0",
"socket.io": "^4.7.2"
"socket.io": "^4.7.2",
"swagger-ui-express": "^5.0.0"
}
}
7 changes: 6 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import cors from "cors";
import api from "./api";
import { initApp } from "./jobs/app.jobs";

import swaggerUi from "swagger-ui-express";
import swaggerDocument from "../docs/api/Token-Price-Oracle-Orchestrator.openapi_collection.json";

const { NODE_PORT, NODE_HOST } = CONFIG;
const app = express();

Expand All @@ -15,9 +18,11 @@ app.use(cors(CONFIG.CORS_OPTIONS));
app.use(bodyParser.json());

const apiRouter = Router();

apiRouter.use("/api", api);
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));

initApp();
initApp();

app.use(apiRouter);
// 404
Expand Down
22 changes: 21 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
"@types/range-parser" "*"
"@types/send" "*"

"@types/express@^4.17.21":
"@types/express@*", "@types/express@^4.17.21":
version "4.17.21"
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.21.tgz#c26d4a151e60efe0084b23dc3369ebc631ed192d"
integrity sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==
Expand Down Expand Up @@ -275,6 +275,14 @@
"@types/mime" "*"
"@types/node" "*"

"@types/swagger-ui-express@^4.1.6":
version "4.1.6"
resolved "https://registry.yarnpkg.com/@types/swagger-ui-express/-/swagger-ui-express-4.1.6.tgz#d0929e3fabac1a96a8a9c6c7ee8d42362c5cdf48"
integrity sha512-UVSiGYXa5IzdJJG3hrc86e8KdZWLYxyEsVoUI4iPXc7CO4VZ3AfNP8d/8+hrDRIqz+HAaSMtZSqAsF3Nq2X/Dg==
dependencies:
"@types/express" "*"
"@types/serve-static" "*"

"@typescript-eslint/eslint-plugin@^6.13.2":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.13.2.tgz#2e03506c5362a65e43cb132c37c9ce2d3cb51470"
Expand Down Expand Up @@ -1920,6 +1928,18 @@ supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"

swagger-ui-dist@>=5.0.0:
version "5.10.5"
resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-5.10.5.tgz#a16e32465c49259045a745f6906fbdb37b4f7ef5"
integrity sha512-Uv8E7hV/nXALQKgW86X1i58gl1O6DFg+Uq54sDwhYqucBBxj/47dLNw872TNILNlOTuPA6dRvUMGQdmlpaX8qQ==

swagger-ui-express@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/swagger-ui-express/-/swagger-ui-express-5.0.0.tgz#7a00a18dd909574cb0d628574a299b9ba53d4d49"
integrity sha512-tsU9tODVvhyfkNSvf03E6FAk+z+5cU3lXAzMy6Pv4av2Gt2xA0++fogwC4qo19XuFf6hdxevPuVCSKFuMHJhFA==
dependencies:
swagger-ui-dist ">=5.0.0"

table-layout@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.2.tgz#c4038a1853b0136d63365a734b6931cf4fad4a04"
Expand Down
Loading