-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
43 lines (28 loc) · 1018 Bytes
/
Copy pathindex.ts
File metadata and controls
43 lines (28 loc) · 1018 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
32
33
34
35
36
37
38
39
40
41
42
43
import express, { Express } from "express";
import bodyParser from "body-parser";
import cors from "cors";
import dotenv from "dotenv";
import path from "path";
import swaggerUi from "swagger-ui-express";
import batchGeocoding from "./routes/batch-geocodig";
import swaggerDocument from "./swagger.json";
const app: Express = express();
const port = process.env.SERVER_PORT;
dotenv.config();
const ROOT_FOLDER = path.join(__dirname, "..");
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cors());
app.use("/public", express.static(path.join(ROOT_FOLDER, "public")));
app.options("*", cors());
const options = {
customCssUrl: "/public/swagger-ui.css",
customSiteTitle: "Batch GeoCoding API - Swagger",
};
app.post("/batch-geocode", batchGeocoding);
app.use("/", swaggerUi.serve);
app.get("/", swaggerUi.setup(swaggerDocument, options));
app.listen(port, () => {
console.log(`[server]: Server is running at http://localhost:${port}`);
});
export default app;