nestjs-unavailable-services
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

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);
  }  
}

Package Sidebar

Install

npm i nestjs-unavailable-services

Weekly Downloads

3

Version

2.0.2

License

MIT

Unpacked Size

6.87 kB

Total Files

7

Last publish

Collaborators

  • tommysack