Api gateway is the facade api for projects
To keep a route safe, use JwtAuthGuard
@UseGuards(JwtAuthGuard)
@Get('profile')
getProfile(@Request() req) {
return req.user;
}
Add your role to role.enums.ts
export enum Role {
Admin = 'admin',
Other = 'other',
}
Now, you can use it on your controllers
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.Admin)
@Get('example')
get(@Request() req) {
return ['Hello world'];
}
Timeout interceptor is global and used to timeout a requisition if it takes more than 10 seconds.
app.useGlobalInterceptors(new TimeoutInterceptor());
To change this time, jump to timeout.interceptor.ts and change this lin:
return next.handle().pipe(timeout(10000));
Health module is used to check if the API itself is up and running and to check other services.
Module to keep users' data saved. It can be used with whatever database the project requires.
$ yarn install
# development
$ yarn start
# watch mode
$ yarn start:dev
# production mode
$ yarn start:prod
# unit tests
$ yarn test
# e2e tests
$ yarn test:e2e
# test coverage
$ yarn test:cov