11import fastify , { FastifyInstance , FastifyServerOptions } from 'fastify'
22import { routes , plugins , setErrorHandler } from './http'
33import { Registry } from 'prom-client'
4+ import { getConfig } from './config'
45
56declare module 'fastify-metrics' {
67 interface IFastifyMetrics {
@@ -9,11 +10,13 @@ declare module 'fastify-metrics' {
910 }
1011}
1112
13+ const { version } = getConfig ( )
14+
1215const 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 )
0 commit comments