nestjs-unavailable-services
v2.0.2
Published
NestJS unavailable services
Downloads
5
Readme
NestJS unavailable services
This is a Middleware to manage the services temporarily unavailable due to maintenance. You can set this parameters:
- appUnavailableFrom is mandatory string of type 'mm/dd/yyyy hh:mm:ss'
- appUnavailableTo is optional string of type 'mm/dd/yyyy hh:mm:ss'
- appUnavailableContentType is optional string, if you doesn't set the parameter then the default is 'application/json; charset=utf-8'
- appUnavailableStatus is optional number, if you doesn't set the parameter then the default is 503
- appUnavailableMessage is optional string, if you doesn't set the parameter then the default is '{"status": "unavailable", "message": "Service unavailable"}'
Installation
$ npm i nestjs-unavailable-services
How to use
If you want to maintain your services in FooController from 12/30/2022 01:00:00 to 12/30/2022 02:00:00, then in your app.module.ts:
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(
ServicesUnavailableMiddlewareCreator({
appUnavailableContentType: 'application/json; charset=utf-8',
appUnavailableStatus: 503,
appUnavailableMessage: '{"status": "unavailable", "message": "Service unavailable from 12/30/2022 01:00:00 to 12/30/2022 02:00:00"}',
appUnavailableFrom: '12/30/2022 01:00:00',
appUnavailableTo: '12/30/2022 02:00:00'
})
)
.forRoutes(FooController);
}
}