README
n9-node-routing
Easily create express app in TypeScript with Decorators
Example :
import { Acl, Body, Get, JsonController, Service, Post } from 'n9-node-routing';
@Service()
@JsonController('/foo')
export class ValidateController {
@Acl([{ action: 'readFoo', user: '@' }])
@Get('/details')
public async getFoo(): Promise<object> {
return {
foo: 'bar',
};
}
@Post('/')
public async createFoo(@Body() body: ElementRequestCreate): Promise<any> {
return body;
}
}
routing-controllers
Wrapper of projectInstall all dependencies and install git hooks with husky :
yarn
Run the project tests:
yarn test
:warning: Some class-validator features changes between v 1.26 and 1.29 :
- The "Custom validation decorators" require a new class instance and not only the class reference/name. Here an example.
- The validation with schema, here is the issue opened
API Documentation
Documentation available as openapi 3.0 format : /documentation.json
Swagger UI for API available at : /documentation
starter
A starter app is available here : https://github.com/neo9/n9-node-microservice-skeleton
Some utils
- Unified HttpClient using got
- Cargo to group multiple small task into a bigger one, for example, multiple http calls
- HttpCargoBuilder a simpler way to build a cargo to group HTTP calls
Tests
To run all test : yarn test
To run a test containing foo : yarn test **/*foo*
To debug a test containing foo : yarn test:dev **/*foo*
it will watch your files a re-run this test each time
Sentry
To use Sentry you only have to ask it to n9-node-routing :
- Basic usage : define the env variable
SENTRY_DSN
and it will activate it with default options. - Fill the sentry options with at least the
dsn
.
Default enabled options are :
- setting the app version in sentry release
- set the NODE_ENV as sentry environment
- enable tracing for ALL requests