-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.ts
35 lines (29 loc) · 857 Bytes
/
server.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import fastify from "fastify";
import { taskRoutes } from "./routes/tasks.route";
import { attachmentsRoutes } from "./routes/attachments.route";
import { userRoutes } from "./routes/user.route";
import { mainScreen } from "./lib/mainScreen";
import cors from "@fastify/cors";
const server = fastify();
server.register(taskRoutes);
server.register(attachmentsRoutes);
server.register(userRoutes);
server.register(cors, {
origin: "*",
});
server.listen({ port: 3000 }, (err, address) => {
if (err) {
console.error(err);
process.exit(1);
}
console.log(`Server listening at ${address}`);
})
server.get("/", async (request, reply) => {
reply.type("text/html");
const html = await mainScreen();
reply.send(html);
});
export default async (req: any, res: any) => {
await server.ready();
server.server.emit("request", req, res);
};