-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add healthz service for health check API endpoint
- Loading branch information
1 parent
62b6e16
commit 7f6907a
Showing
4 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
packages/server/core/src/services/healthz/healthz.class.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ServiceMethods } from '@feathersjs/feathers' | ||
import { Application } from '../../declarations' | ||
|
||
export type HealthzServiceMethods = Pick<ServiceMethods<any>, 'get'> | ||
|
||
class HealthzService implements HealthzServiceMethods { | ||
app: Application | ||
|
||
constructor(app: Application) { | ||
this.app = app | ||
} | ||
|
||
async get(): Promise<{ status: string; timestamp: string }> { | ||
return { | ||
status: 'OK', | ||
timestamp: new Date().toISOString(), | ||
} | ||
} | ||
} | ||
|
||
export const healthz = (app: Application): void => { | ||
app.use('/healthz', new HealthzService(app)) | ||
} | ||
|
||
declare module '../../declarations' { | ||
interface ServiceTypes { | ||
'/healthz': HealthzService | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.