Skip to content

Commit

Permalink
refactor: Add healthz service for health check API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
coffeeorgreentea committed Jul 19, 2024
1 parent 62b6e16 commit 7f6907a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
29 changes: 29 additions & 0 deletions packages/server/core/src/services/healthz/healthz.class.ts
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
}
}
2 changes: 2 additions & 0 deletions packages/server/core/src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { pluginState } from './state/plugin-state-service'
import { pluginCommand } from './commands/plugin-command-service'
import { presigner } from './presigner/presigner-service'
import { agentChannel } from './agentChannels/agentChannels'
import { healthz } from './healthz/healthz.class'

// For more information about this file see https://dove.feathersjs.com/guides/cli/application.html#configure-functions
import type { Application } from '../declarations'
Expand Down Expand Up @@ -43,6 +44,7 @@ export const services = async (app: Application): Promise<void> => {
app.configure(pluginCommand)
app.configure(presigner)
app.configure(agentChannel)
app.configure(healthz)

// Wait for a tick to handle race condition
// TODO: handle this race condition better
Expand Down
4 changes: 2 additions & 2 deletions packages/server/db/src/lib/prisma/client-core/edge.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/server/db/src/lib/prisma/client-core/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7f6907a

Please sign in to comment.