-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
52 lines (44 loc) · 1.32 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
import bodyParser from "body-parser";
import express from "express";
import swaggerJSDoc from "swagger-jsdoc";
import swaggerUi from "swagger-ui-express";
import jokeRoutes = require("./apis/v1.0/jokes/routes");
import home = require("./app/home");
import databaseInit = require("./database/init");
const version = "v1.0";
const apiPath = "/apis/" + version;
const port = 3050;
const rootPath = "http://localhost:" + port;
const apiFullPath = rootPath + apiPath;
const app = express();
const db = databaseInit.setup();
// parse application/json
app.use(bodyParser.json());
const swaggerDefinition = {
basePath: apiPath,
info: {
description: "Admin API suite for the Healthera joke system.",
title: "Healthera Jokes",
version,
},
tags: [{
description: "APIs for managing jokes",
name: "jokes",
}],
};
const options = {
apis: ["./apis/v1.0/jokes/*.ts"],
swaggerDefinition,
};
const swaggerSpec = swaggerJSDoc(options);
// Configure APIs
app.disable("etag");
app.use("/apis/v1.0/docs", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
jokeRoutes.setup(app, db, apiPath);
// Configure App
home.setup(app, apiFullPath);
// Start
app.listen(port, () => {
console.log("Visit " + rootPath + "/home for app");
console.log("Visit " + apiFullPath + "/docs for admin APIs");
});