MMI Staking - Connector boilerplate (NestJS)
A boilerplate NestJS application to run and host your Connector, and integrate with MMI Staking (Beta).
Implements the required OpenAPI Specification and pre-configures an OAuth M2M authentication.
Setup
In this repository we use a specific NodeJS
version, 16
. We recommend you use nvm
to manage Node.js
versions seamlessly. To install it and use the correct Node.js version read the instructions here.
npm i
Create a .env
file, copying it from .env.sample
.
Configuring Authentication
If you want to authenticate your endpoints using OAuth M2M, the boilerplate is pre-configured with everything you need. In .env
, set these up, with your own OAuth values:
AUTH_ISSUER_URL=XXX
AUTH_AUDIENCE=XXX
FYI, these are used in the file src/auth/jwt.strategy.ts. Find more details about configuration in the Passport documentation.
The boilerplate doesn't ship with an example for API Key authentication. Implementation details are up to up, but you can use a similar implementation with Passport.
Development
npm run start:dev
Some of the following commands are avaliable to help you on your everyday programming
Linting
npm run lint
Formatting
npm run format
Testing
Unit tests can be run using
npm run test
or if you want to see test coverage
npm run test:cov
Integration tests can be ran using
npm run test:integration
Documentation
This boilerplate comes with NestJS' Swagger integration. By correctly naming your controllers and taking advantage of the plugin's decorators you can automatically generate Swagger documentation. To take a look at how this documentation looks run the project using
npm run start
and then visit http://localhost:3000/docs