1
0
Fork 0
mirror of https://github.com/kou029w/quot.git synced 2025-01-18 16:08:03 +00:00
quot/app/controllers/index.ts
2022-09-07 05:51:57 +09:00

21 lines
638 B
TypeScript

import fastify, { type FastifyInstance } from "fastify";
import defaultConfig, { type Config } from "./config";
import routes from "./routes/index";
declare module "fastify" {
interface FastifyInstance {
config: Config;
}
}
export function App(config: Config = defaultConfig()): FastifyInstance {
const app = fastify({ logger: { stream: process.stderr, level: "warn" } });
app.decorate("config", config).register(routes);
return app;
}
export async function start(app: FastifyInstance): Promise<string> {
await app.ready();
const address = await app.listen({ host: "::", port: app.config.port });
return address;
}