Move providers from app to routes

This commit is contained in:
Asher
2020-10-15 17:47:20 -05:00
parent 6000e389bc
commit 9f25cc6d5d
8 changed files with 7 additions and 7 deletions

22
src/node/routes/health.ts Normal file
View File

@@ -0,0 +1,22 @@
import { Heart } from "../heart"
import { HttpProvider, HttpProviderOptions, HttpResponse } from "../http"
/**
* Check the heartbeat.
*/
export class HealthHttpProvider extends HttpProvider {
public constructor(options: HttpProviderOptions, private readonly heart: Heart) {
super(options)
}
public async handleRequest(): Promise<HttpResponse> {
return {
cache: false,
mime: "application/json",
content: {
status: this.heart.alive() ? "alive" : "expired",
lastHeartbeat: this.heart.lastHeartbeat,
},
}
}
}