generated from nhcarrigan/template
31 lines
745 B
TypeScript
31 lines
745 B
TypeScript
/**
|
|
* @copyright nhcarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
import fastify from "fastify";
|
|
import { generateHtml } from "../modules/generateHtml.js";
|
|
import { sendDebugLog } from "../utils/sendDebugLog.js";
|
|
import type { App } from "../interfaces/app.js";
|
|
|
|
/**
|
|
* Instantiates the fastify server.
|
|
* @param app - The application instance.
|
|
*/
|
|
export const serve = (app: App): void => {
|
|
const server = fastify({
|
|
logger: false,
|
|
});
|
|
|
|
server.get("/", (_request, response) => {
|
|
response.header("Content-Type", "text/html");
|
|
response.send(generateHtml(app));
|
|
});
|
|
|
|
server.listen({ port: 12_443 }, () => {
|
|
void sendDebugLog({
|
|
content: "Server listening on port 12443.",
|
|
});
|
|
});
|
|
};
|