1- import Fastify , { type FastifyInstance } from 'fastify' ;
1+ import Fastify , { type FastifyInstance } from 'fastify' ;
22import fastifyCors from '@fastify/cors' ;
3- import type { ConfigType } from '../shared/config/config_schema.js' ;
4- import type { Logger } from '../shared/logger/logger.js' ;
3+ import type { ConfigType } from '../shared/config/config_schema.js' ;
4+ import type { Logger } from '../shared/logger/logger.js' ;
55import TranscriptionEngine from './services/transcription_engine.js' ;
66import fastifyWebsocket from '@fastify/websocket' ;
77import websocketHandler from './routes/websocket_handler.js' ;
@@ -30,7 +30,7 @@ declare module 'fastify' {
3030 * @returns created fastify server
3131 */
3232export default function createServer ( config : ConfigType , logger : Logger ) {
33- const fastify = Fastify ( { loggerInstance : logger } ) as unknown as FastifyInstance ;
33+ const fastify = Fastify ( { loggerInstance : logger } ) as unknown as FastifyInstance ;
3434
3535 fastify . register ( fastifyWebsocket ) ;
3636
@@ -49,10 +49,15 @@ export default function createServer(config: ConfigType, logger: Logger) {
4949 fastify . decorate ( 'tokenService' , new TokenService ( config , logger ) ) ;
5050 fastify . decorate ( 'authenticationService' , new AuthenticationService ( config , fastify . tokenService ) ) ;
5151
52- // Register routes
53- fastify . register ( websocketHandler ) ;
54- fastify . register ( accessTokenHandler ) ;
55- fastify . register ( healthcheckHandler ) ;
52+ fastify . register (
53+ async ( api , _options ) => {
54+ api . register ( websocketHandler , ) ;
55+ api . register ( accessTokenHandler ) ;
56+ api . register ( healthcheckHandler ) ;
57+
58+ } ,
59+ { prefix : "/api" } ,
60+ ) ;
5661
5762 return fastify ;
5863}
0 commit comments