-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
41 lines (36 loc) · 943 Bytes
/
index.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
36
37
38
39
40
41
import { fastifyEnv } from "@fastify/env";
import fastifySentry from "@immobiliarelabs/fastify-sentry";
import fastify from "./app";
declare module "fastify" {
interface FastifyInstance {
config: {
WEBHOOK_SECRET: string;
DISCORD_WEBHOOK_URL: string;
SENTRY_DSN: string;
};
}
}
const schema = {
type: "object",
required: ["WEBHOOK_SECRET", "DISCORD_WEBHOOK_URL", "SENTRY_DSN"],
properties: {
WEBHOOK_SECRET: { type: "string" },
DISCORD_WEBHOOK_URL: { type: "string" },
SENTRY_DSN: { type: "string" },
},
};
const start = async () => {
try {
await fastify.register(fastifyEnv, { schema, dotenv: true });
await fastify
.register(fastifySentry, { dsn: fastify.config.SENTRY_DSN })
.listen({
host: "RENDER" in process.env ? "0.0.0.0" : "localhost",
port: 3000,
});
} catch (err) {
fastify.log.error(err);
process.exit(1);
}
};
start();