Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1x 1x 1x 1x 1x 1x 8x 8x 16x 16x 8x 8x 8x 8x 8x 8x 8x | import Fastify from "fastify";
import proxy from "./proxy";
import dirs from "./dirs";
import spa from "./spa";
import { responseLogger } from "./logger";
import type { DevServerConfig } from "./config";
export async function init(
config: Partial<DevServerConfig> = {},
): Promise<any> {
const server = Fastify(config.server as any);
server.addHook("onSend", async (_: any, reply: any, payload: unknown) => {
reply.header("X-Response-Time", reply.elapsedTime);
return payload;
});
await server.register(proxy as any, config);
await server.register(dirs as any, config);
await server.register(spa as any, { ...config, prefix: config.basePath });
await server.register(responseLogger as any, { silent: config.silent });
Iif (config.extend) await server.register(config.extend as any, config);
await server.ready();
return server;
}
|