-
Notifications
You must be signed in to change notification settings - Fork 0
/
serve.ts
38 lines (29 loc) · 1.02 KB
/
serve.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
import "dotenv/config";
import app from "./app/app";
import express from "express";
import swaggerUi from "swagger-ui-express";
import swaggerDocumetation from "./swagger.json";
import { Request, Response } from "express";
const PORT = process.env.PORT || 3333;
const serve = app.serve();
serve.use("/public", express.static("public"))
serve.get("/home", (_request: Request, response: Response) => {
return response.sendFile(__dirname + "/public/index.html")
});
serve.use("/doc", swaggerUi.serve);
serve.get("/doc", swaggerUi.setup(swaggerDocumetation));
serve.get("/swagger", (_request: Request, response: Response) => {
return response.sendFile(__dirname + "/swagger.json")
})
serve.get("/docs", (_request: Request, response: Response) => {
return response.sendFile(__dirname + "/index.html")
})
serve.listen(PORT, callback);
function callback(){
return console.log(`
Serve is running PORT: ${PORT}
- http://localhost:${PORT}/
- http://localhost:${PORT}/home
- http://localhost:${PORT}/docs
`);
}