generated from nhcarrigan/template
feat: initial app prototype
This commit is contained in:
30
src/server/serve.ts
Normal file
30
src/server/serve.ts
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @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.",
|
||||
});
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user