-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathapp.js
More file actions
62 lines (55 loc) · 1.51 KB
/
app.js
File metadata and controls
62 lines (55 loc) · 1.51 KB
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
54
55
56
57
58
59
60
61
62
// IMPORT MODULES
const Fastify = require("fastify");
const { version } = require("./package.json");
function builder() {
const fastify = Fastify({
ignoreTrailingSlash: true,
ajv: {
customOptions: {
strict: false,
validateFormats: false
}
}
});
// Homepage route? Replace later.
fastify.get("/", async () => {
return {
Test: "This is working fine. Try Endpoint '/api/docs/static/index.html' ;-) ",
};
});
// SET UP Swagger
fastify.register(require("@fastify/swagger"), {
routePrefix: "/api/docs",
swagger: {
info: {
title: "Test Adserver API",
description: "Lightweight test ad server to validate ad tracking.",
version: version,
},
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;