relay/src/modules/app.ts

25 lines
613 B
TypeScript

import { AddressInfo } from "net";
import log from "./log.js";
import fastify from "fastify";
import type { FastifyInstance } from "fastify";
import { getKeyPair } from "../lib/seed.js";
let app: FastifyInstance;
export async function start() {
const keyPair = getKeyPair();
app = fastify({
logger: true,
});
await app.listen({ port: 80, host: "0.0.0.0" });
app.get("/", (req, res) => {
res.send(Buffer.from(keyPair.publicKey).toString("hex"));
});
const address = app.server.address() as AddressInfo;
log.info("HTTP/App Server started on ", `${address.address}:${address.port}`);
}