generated from multiversx/mx-template-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1a7cb56
Showing
118 changed files
with
24,759 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module.exports = { | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint/eslint-plugin'], | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
// 'plugin:prettier/recommended', | ||
], | ||
root: true, | ||
env: { | ||
node: true, | ||
jest: true, | ||
}, | ||
rules: { | ||
"@typescript-eslint/no-explicit-any": ["off"], | ||
"@typescript-eslint/no-unused-vars": ["off"], | ||
"@typescript-eslint/ban-ts-comment": ["off"], | ||
"@typescript-eslint/no-empty-function": ["off"], | ||
"@typescript-eslint/ban-types": ["off"], | ||
"@typescript-eslint/no-var-requires": ["off"], | ||
"@typescript-eslint/no-inferrable-types": ["off"], | ||
"require-await": ["error"], | ||
"@typescript-eslint/no-floating-promises": ["error"], | ||
"max-len": ["off"], | ||
"semi": ["error"], | ||
"comma-dangle": ["error", "always-multiline"], | ||
"eol-last": ["error"], | ||
}, | ||
ignorePatterns: ['.eslintrc.js'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Type | ||
|
||
- [ ] Bug | ||
- [ ] Feature | ||
- [ ] Refactoring | ||
- [ ] Performance improvement | ||
|
||
## Problem setting | ||
|
||
- | ||
- | ||
- | ||
|
||
## Proposed Changes | ||
|
||
- | ||
- | ||
- | ||
|
||
## How to test | ||
|
||
- | ||
- | ||
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: ESLint | ||
|
||
on: | ||
push: | ||
branches: [main, development] | ||
pull_request: | ||
branches: [main, development] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm ci | ||
- run: npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# compiled output | ||
/dist | ||
/node_modules | ||
build.yaml | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# OS | ||
.DS_Store | ||
|
||
# Tests | ||
/coverage | ||
/.nyc_output | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
# Configs | ||
**/*/config/config.yaml | ||
**/*/config/config.custom.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "attach", | ||
"name": "Attach NestJS WS", | ||
"port": 9229, | ||
"restart": true, | ||
"stopOnEntry": false, | ||
"protocol": "inspector" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": true | ||
}, | ||
"eslint.validate": [ | ||
"javascript" | ||
], | ||
"editor.formatOnSave": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
REST API facade template for microservices that interacts with the MultiversX blockchain. | ||
|
||
## Quick start | ||
|
||
1. Run `npm install` in the project directory | ||
2. Optionally make edits to `config.yaml` or create `config.custom.yaml` for each microservice | ||
|
||
## Dependencies | ||
|
||
1. Redis Server is required to be installed [docs](https://redis.io/). | ||
2. MySQL Server is required to be installed [docs](https://dev.mysql.com/doc/refman/8.0/en/installing.html). | ||
3. MongoDB Server is required to be installed [docs](https://docs.mongodb.com/). | ||
|
||
You can run `docker-compose up` in a separate terminal to use a local Docker container for all these dependencies. | ||
|
||
After running the sample, you can stop the Docker container with `docker-compose down` | ||
|
||
## Available Features | ||
|
||
These features can be enabled/disabled in config file | ||
|
||
### `Public API` | ||
|
||
Endpoints that can be used by anyone (public endpoints). | ||
|
||
### `Private API` | ||
|
||
Endpoints that are not exposed on the internet | ||
For example: We do not want to expose our metrics and cache interactions to anyone (/metrics /cache) | ||
|
||
### `Cache Warmer` | ||
|
||
This is used to keep the application cache in sync with new updates. | ||
|
||
### `Transaction Processor` | ||
|
||
This is used for scanning the transactions from MultiversX Blockchain. | ||
|
||
### `Queue Worker` | ||
|
||
This is used for concurrently processing heavy jobs. | ||
|
||
### `Grafana dashboard` | ||
|
||
You can find a predefined Grafana dashboard with basic metrics at [http://localhost:3010](http://localhost:3010) | ||
|
||
Use `admin` for user and password fields. Then navigate to `Dashboards` -> `Template Service` | ||
|
||
## Available Scripts | ||
|
||
This is a MultiversX project built on Nest.js framework. | ||
|
||
### `npm run start:mainnet` | ||
|
||
| ||
Runs the app in the production mode. | ||
Make requests to [http://localhost:3001](http://localhost:3001). | ||
|
||
Redis Server is required to be installed. | ||
|
||
## Running the api | ||
|
||
```bash | ||
# development watch mode on devnet | ||
$ npm run start:devnet:watch | ||
|
||
# development debug mode on devnet | ||
$ npm run start:devnet:debug | ||
|
||
# development mode on devnet | ||
$ npm run start:devnet | ||
|
||
# production mode | ||
$ npm run start:mainnet | ||
``` | ||
|
||
## Running the transactions-processor | ||
|
||
```bash | ||
# development watch mode on devnet | ||
$ npm run start:transactions-processor:devnet:watch | ||
|
||
# development debug mode on devnet | ||
$ npm run start:transactions-processor:devnet:debug | ||
|
||
# development mode on devnet | ||
$ npm run start:transactions-processor:devnet | ||
|
||
# production mode | ||
$ npm run start:transactions-processor:mainnet | ||
``` | ||
|
||
## Running the queue-worker | ||
|
||
```bash | ||
# development watch mode on devnet | ||
$ npm run start:queue-worker:devnet:watch | ||
|
||
# development debug mode on devnet | ||
$ npm run start:queue-worker:devnet:debug | ||
|
||
# development mode on devnet | ||
$ npm run start:queue-worker:devnet | ||
|
||
# production mode | ||
$ npm run start:queue-worker:mainnet | ||
``` | ||
|
||
Requests can be made to http://localhost:3001 for the api. The app will reload when you'll make edits (if opened in watch mode). You will also see any lint errors in the console. | ||
|
||
### `npm run test` | ||
|
||
```bash | ||
# unit tests | ||
$ npm run test | ||
|
||
# e2e tests | ||
$ npm run test:e2e | ||
|
||
# test coverage | ||
$ npm run test:cov | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
urls: | ||
api: 'https://devnet-api.multiversx.com' | ||
swagger: | ||
- 'https://devnet-microservice.multiversx.com' | ||
- 'https://testnet-microservice.multiversx.com' | ||
- 'https://microservice.multiversx.com' | ||
redis: '127.0.0.1' | ||
database: | ||
host: 'localhost' | ||
port: 3306 | ||
username: 'root' | ||
password: 'root' | ||
name: 'example' | ||
features: | ||
publicApi: | ||
enabled: true | ||
port: 3000 | ||
privateApi: | ||
enabled: true | ||
port: 4000 | ||
keepAliveAgent: | ||
enabled: true | ||
nativeAuth: | ||
maxExpirySeconds: | ||
acceptedOrigins: | ||
- utils.multiversx.com | ||
security: | ||
admins: | ||
rateLimiterSecret: | ||
keepAliveTimeout: | ||
downstream: 61000 | ||
upstream: 60000 | ||
useCachingInterceptor: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
urls: | ||
api: 'https://api.multiversx.com' | ||
swagger: | ||
- 'https://microservice.multiversx.com' | ||
- 'https://devnet-microservice.multiversx.com' | ||
- 'https://testnet-microservice.multiversx.com' | ||
redis: '127.0.0.1' | ||
database: | ||
host: 'localhost' | ||
port: 3306 | ||
username: 'root' | ||
password: 'root' | ||
name: 'example' | ||
features: | ||
publicApi: | ||
enabled: true | ||
port: 3000 | ||
privateApi: | ||
enabled: true | ||
port: 4000 | ||
keepAliveAgent: | ||
enabled: true | ||
nativeAuth: | ||
maxExpirySeconds: | ||
acceptedOrigins: | ||
- utils.multiversx.com | ||
security: | ||
admins: | ||
rateLimiterSecret: | ||
keepAliveTimeout: | ||
downstream: 61000 | ||
upstream: 60000 | ||
useCachingInterceptor: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
urls: | ||
api: 'https://testnet-api.multiversx.com' | ||
swagger: | ||
- 'https://testnet-microservice.multiversx.com' | ||
- 'https://devnet-microservice.multiversx.com' | ||
- 'https://microservice.multiversx.com' | ||
redis: '127.0.0.1' | ||
database: | ||
host: 'localhost' | ||
port: 3306 | ||
username: 'root' | ||
password: 'root' | ||
name: 'example' | ||
features: | ||
publicApi: | ||
enabled: true | ||
port: 3000 | ||
privateApi: | ||
enabled: true | ||
port: 4000 | ||
keepAliveAgent: | ||
enabled: true | ||
nativeAuth: | ||
maxExpirySeconds: | ||
acceptedOrigins: | ||
- utils.multiversx.com | ||
security: | ||
admins: | ||
rateLimiterSecret: | ||
keepAliveTimeout: | ||
downstream: 61000 | ||
upstream: 60000 | ||
useCachingInterceptor: true |
Oops, something went wrong.