- Prerequisites
- Installing
- Testing
- Register clients
- Interface
- Database Schema Migration
- Docker
- NVM
We use docker to run our dependencies like mongo and ganache in. We run the development server locally, managing a common node version using Node Version Manager. You can also manually install the correct node version but usage of NVM is recommended.
# 1. Install/activate current nodejs defined in .nvmrc
nvm use
# 2. Provide environment variables
cp .env.example .env
# 3. Create certificates (Make sure to have openssl@1.1 or openssl@3 installed.)
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout auth.key -out auth.crt -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost"
# 3. Checkout SCSS submodule
git submodule init
git submodule update
# 4. Install packages
npm install --ci
# 5. Start working (docker compose up -d && npm run watch:debug)
npm run dev
# 6. shut down dependencies
docker compose down
# Run e2e tests
npm run test
POST http://localhost:3000/reg
{
"application_type": "web",
"client_name": "Your App",
"grant_types": ["client_credentials"],
"redirect_uris": [],
"response_types": [],
"scope": "openid account:read account:write asset_pools:read asset_pools:write rewards:read members:read members:write withdrawals:write"
}
POST http://localhost:3000/reg
{
"application_type": "web",
"client_name": "THX Wallet",
"grant_types": ["authorization_code"],
"redirect_uris": ["https://dev.wallet.thx.network/signin-oidc"],
"post_logout_redirect_uris": ["https://dev.wallet.thx.network"],
"response_types": ["code"],
"scope": "openid email offline_access deposits:read deposits:write asset_pools:read asset_pools:write rewards:read withdrawals:read"
}
Swagger Documentation is provided in the controllers of the routes and lives at the following endpoints:
npm run migrate:create name-of-my-script
A new file will be created inside migrations folder with a corresponding timestamp.
|_ migrations/
|- 20210108114324-name-of-my-script.js
Considering we want to add a quantity property to the products collection, the migration could be as follows:
export = {
async up(db: Db) {
return db.collection('products').updateMany({}, { $set: { quantity: 10 } });
},
async down(db: Db) {
return db.collection('products').updateMany({}, { $unset: { quantity: null } });
},
};
To get the migration status
npm run migrate:status
To run your migrations, simply run the command
npm run migrate
To rollback a migration use the down command
npm run migrate:undo-last