-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (25 loc) · 986 Bytes
/
server.js
File metadata and controls
32 lines (25 loc) · 986 Bytes
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
import http from "http";
import express from "express";
import { initialize, use } from "@oas-tools/core";
const _ContentTypeMiddleware = (_, res, next) => {
res.setHeader('Content-Type', 'application/json');
next();
};
const deploy = async () => {
const serverPort = process.env.PORT ?? 8080;
const app = express();
use(_ContentTypeMiddleware, {}, 0);
use(express.json({limit: '50mb'}), {}, 0);
initialize(app).then(() => {
http.createServer(app).listen(serverPort, () => {
console.log("\nApp running at http://localhost:" + serverPort);
console.log("________________________________________________________________");
console.log('API docs (Swagger UI) available on http://localhost:' + serverPort + '/docs');
console.log("________________________________________________________________");
});
});
}
const undeploy = () => {
process.exit();
};
export default {deploy, undeploy}