Skip to content

tommysack/nestjs-unavailable-services

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

NestJS unavailable services

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published