-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
35 lines (27 loc) · 748 Bytes
/
index.ts
File metadata and controls
35 lines (27 loc) · 748 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
import express from "express";
import cors from "cors";
import helmet from "helmet";
import { createServer } from "http";
import compression from "compression";
import route from "./src/routes/apiRoute";
import morgan from "morgan";
const app = express();
const httpServer = createServer(app);
app.use(compression());
require("dotenv").config();
app.use(cors({
origin: '*'
}));
app.use(helmet());
app.use(express.json());
app.use(morgan("tiny"));
app.use("/", route);
const port = process.env.PORT;
let server = httpServer.listen(port ?? 3010, function () {
console.log(`⚡️[server]: Server is running at http://localhost:${port}`);
});
function stop() {
server.close();
}
module.exports = server;
module.exports.stop = stop;