-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.js
53 lines (46 loc) · 1.27 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// IMPORT MODULES
const Fastify = require("fastify");
function builder() {
const fastify = Fastify({ ignoreTrailingSlash: true });
// Homepage route? Replace later.
fastify.get("/", async () => {
return {
Test: "This is working fine",
};
});
// SET UP Swagger
fastify.register(require("fastify-swagger"), {
routePrefix: "/api/docs",
swagger: {
info: {
title: "Test Adserver API",
description: "This is for testing.",
version: "0.2.0",
},
tags: [
{ name: "sessions", description: "Session related end-points" },
{ name: "users", description: "User related end-points" },
{ name: "vast", description: "VAST related end-points" },
{ name: "vmap", description: "VMAP related end-points" },
],
securityDefinitions: {
apiKey: {
type: "apiKey",
name: "x-api-key",
in: "header",
},
},
},
exposeRoute: true,
});
fastify.register(require("./api/routes.js"), {
prefix: "/api/v1",
});
fastify.register(require("fastify-cors"), {});
fastify.ready((err) => {
if (err) throw err;
fastify.swagger();
});
return fastify;
}
module.exports = builder;