Something went wrong. Try again.
プレイグラウンド、サンドボックス、使い捨てスクリプト置き場
Something went wrong. Try again.
12345678910111213141516171819202122232425262728import fastify, { FastifyInstance } from "fastify";import autoload from "fastify-autoload";import path from "node:path";
type Options = { isDev?: boolean; quiet?: boolean;};
type Server = FastifyInstance;
export function create(options: Options): Server { const app = fastify({ logger: !options.quiet && { prettyPrint: options.isDev }, }); app.register(autoload, { dir: path.resolve(__dirname, "routes"), routeParams: true, }); return app;}
export async function start(server: Server, port: string): Promise<string> { await server.ready(); const address: string = await server.listen(port, "::"); return address;}