-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (28 loc) · 817 Bytes
/
index.js
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
36
import Fastify from "fastify";
import cors from "@fastify/cors";
import autoload from "@fastify/autoload";
import { PrismaClient } from "@prisma/client";
import { join } from "node:path";
import config from "./config.json" assert { type: "json" };
import "./tasks/traceGuildsCount.js";
const fastify = Fastify({
trustProxy: true,
ignoreTrailingSlash: true
});
fastify.register(cors);
fastify.register(autoload, {
dir: join(process.cwd(), "routes"),
routeParams: true
});
const prisma = new PrismaClient();
(async () => {
try {
const { port, host } = config;
await fastify.listen({ port, host });
console.log(`Fastify server is running on ${host}:${port}.`);
} catch(err) {
console.error(err.stack);
process.exit(1);
}
})();
export { prisma }