forked from bellshade/bellshade-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
25 lines (19 loc) · 836 Bytes
/
app.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
const path = require("path");
const fastify = require("fastify")({
logger: process.env.NODE_ENV !== "production" ? true : "info", // info only when prod
});
const { leaderboard, main } = require("./router");
const { fastifySchedulePlugin } = require("fastify-schedule");
// plugin
fastify.register(require("fastify-compress"));
fastify.register(require("fastify-cors"), require("./config/cors"));
fastify.register(require("fastify-swagger"), require("./config/swagger"));
fastify.register(fastifySchedulePlugin);
fastify.register(require("fastify-autoload"), {
dir: path.join(__dirname, "plugin"),
});
const cachePreHandler = require("./common/cachePreHandler")(fastify);
// routing
fastify.register(main(cachePreHandler));
fastify.register(leaderboard(cachePreHandler), { prefix: "/leaderboard" });
module.exports = fastify;