mirror of
https://github.com/FJurmanovic/sugarr.git
synced 2026-11-11 07:41:08 +00:00
18 lines
506 B
TypeScript
18 lines
506 B
TypeScript
import Fastify, { type FastifyInstance } from 'fastify';
|
|
import type { Controller } from './Controller';
|
|
import { registerAuthHook } from './authHook';
|
|
|
|
export interface BuildServerOptions {
|
|
secretKey: string;
|
|
controllers: Controller[];
|
|
}
|
|
|
|
export function buildServer(options: BuildServerOptions): FastifyInstance {
|
|
const app = Fastify({ logger: false });
|
|
registerAuthHook(app, options.secretKey);
|
|
for (const controller of options.controllers) {
|
|
controller.register(app);
|
|
}
|
|
return app;
|
|
}
|