🌳
pt0/nextF/serverF/healthCheckHandlerF.mts
1import type { ServerResponse } from 'http'
3let isLive = false
5export const markLive = () => {
6 isLive = true
7}
9const probeHandlers: Record<string, (res: ServerResponse) => void> = {
10 liveness: (res) => {
11 if (isLive) {
12 res.statusCode = 200
13 res.end('OK')
14 } else {
15 res.statusCode = 500
16 res.end('NOT OK')
17 }
18 },
21export const handleProbe = (type: string, res: ServerResponse) => {
22 const handler = probeHandlers[type]
23 if (handler) {
24 handler(res)
25 } else {
26 res.statusCode = 404
27 res.end('NOT FOUND')
28 }