Skip to content

Commit cce047b

Browse files
authored
feat: add version endpoint to admin api (#811)
1 parent 53e803c commit cce047b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/admin-app.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fastify, { FastifyInstance, FastifyServerOptions } from 'fastify'
22
import { routes, plugins, setErrorHandler } from './http'
33
import { Registry } from 'prom-client'
4+
import { getConfig } from './config'
45

56
declare module 'fastify-metrics' {
67
interface IFastifyMetrics {
@@ -9,11 +10,13 @@ declare module 'fastify-metrics' {
910
}
1011
}
1112

13+
const { version } = getConfig()
14+
1215
const build = (opts: FastifyServerOptions = {}, appInstance?: FastifyInstance): FastifyInstance => {
1316
const app = fastify(opts)
1417
app.register(plugins.signals)
1518
app.register(plugins.adminTenantId)
16-
app.register(plugins.logRequest({ excludeUrls: ['/status', '/metrics', '/health'] }))
19+
app.register(plugins.logRequest({ excludeUrls: ['/status', '/metrics', '/health', '/version'] }))
1720
app.register(routes.tenants, { prefix: 'tenants' })
1821
app.register(routes.objects, { prefix: 'tenants' })
1922
app.register(routes.jwks, { prefix: 'tenants' })
@@ -49,6 +52,9 @@ const build = (opts: FastifyServerOptions = {}, appInstance?: FastifyInstance):
4952
app.register(plugins.metrics({ enabledEndpoint: true }))
5053
}
5154

55+
app.get('/version', (_, reply) => {
56+
reply.send(version)
57+
})
5258
app.get('/status', async (_, response) => response.status(200).send())
5359

5460
setErrorHandler(app)

src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const build = (opts: buildOpts = {}): FastifyInstance => {
5454
app.register(plugins.tenantId)
5555
app.register(plugins.metrics({ enabledEndpoint: !isMultitenant }))
5656
app.register(plugins.tracing)
57-
app.register(plugins.logRequest({ excludeUrls: ['/status', '/metrics', '/health'] }))
57+
app.register(plugins.logRequest({ excludeUrls: ['/status', '/metrics', '/health', '/version'] }))
5858
app.register(routes.tus, { prefix: 'upload/resumable' })
5959
app.register(routes.bucket, { prefix: 'bucket' })
6060
app.register(routes.object, { prefix: 'object' })

0 commit comments

Comments
 (0)