-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
43 lines (39 loc) · 1005 Bytes
/
server.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
37
38
39
40
41
42
43
const fastify = require("fastify")({ logger: true });
const PORT = 3200;
const registerRouters = require("./routes/registerRouters");
const createWSEndpoint = require("./utils/createWSEndpoint");
// Register the fastify swagger
fastify.register(require("fastify-swagger"), {
routePrefix: "/docs",
swagger: {
info: {
title: "Search API",
description: "Search API",
version: "1.0.0",
},
},
exposeRoute: true,
consumes: ["application/json"],
produces: ["application/json"],
uiConfig: {
docExpansion: "full",
deepLinking: false,
},
staticCSP: true,
transformStaticCSP: (header) => header,
});
// Register the routers
registerRouters(fastify);
// Start server function
async function startServer() {
try {
// Create an endpoint
await createWSEndpoint();
await fastify.listen(PORT);
} catch (error) {
// if an error occurs print the error and exit the program
fastify.log.error(error);
process.exit(1);
}
}
startServer();