Terminus plugin
See original GitHub issueInformations
Is your feature request related to a problem? Please describe. Adding an implementation of terminus library. This can be used to create a route which determine if our app is health or unhealth.
Describe the solution you’d like
Add a @Health
decorator based on the terminus library. Nest have his own implementation of the terminus library for example.
import { Health } from "@tsed/terminus";
@Controller("/health")
export class HealthController {
@Health()
public health() {
// determine is the app is health or not
}
}
Describe alternatives you’ve considered Currently, I have just create a simple controller and service which check if my database is up or not. This work but it does not cover all the cases covered by terminus :
HealthService.ts
import { Inject, Service } from '@tsed/di';
import { MongooseService } from '@tsed/mongoose';
import { version } from '../../package.json';
@Service()
export default class HealthService {
@Inject(MongooseService)
public mongoose: MongooseService;
public health() {
const { readyState } = this.mongoose.get();
if (readyState === 0 || readyState === 2 || readyState === 3) {
return Promise.reject(new Error());
}
return Promise.resolve({ version });
}
}
HealthController.ts
import { Controller, Get, Inject } from '@tsed/common';
import HealthService from './HealthService';
@Controller('/health')
export default class HealthController {
@Inject(HealthService)
private healthService: HealthService;
@Get()
public async health() {
try {
const { version } = await this.healthService.health();
return {
status: 'ok',
version,
};
} catch (error) {
return { status: 'error' };
}
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Install Plugins | Terminus Guide | Pantheon Docs
Install Plugins. Terminus ships with a plugin manager. You can use a Terminus command like the example below to install a plugin: terminus...
Read more >Terminus Plugin Project - GitHub
Terminus plugin to automate the process of updating a site through the upstream. This performs a backup before applying upstream updates.
Read more >Terminus — QGIS Python Plugins Repository
Terminus Plugin icon ... A plugin to perform Image Segmentation. It requires the installation of Scikit-image Python library. For more information please visit ......
Read more >pantheon-systems/terminus-plugin-example - Packagist
A simple plugin for Terminus-CLI to demonstrate how to add new commands. Adds commands 'hello' and 'auth:hello' to Terminus. Learn more about Terminus...
Read more >Terminus - Package Control
Bring a real terminal to Sublime Text · Windows support · continuous history · easily customizable themes (see Terminus Utilities) · unicode support...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Our implementation for graceful-shutdown with terminus. It’s not well-tested code, but I hope it helps you.
https://github.com/weseek/growi/commit/7246df4f761d5bd50f60f23fe1d48faf339e70b5
Thanks ! I don’t have lot of free time now but when I can, I will take a look to this feature !