-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (28 loc) · 817 Bytes
/
index.js
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
import express from "express";
import http from "http";
import bodyParser from "body-parser";
import cors from "cors";
import * as dotenv from "dotenv";
import routes from "./routes/index.js";
import { connectToDB } from "./db/config.js";
import { startWorker } from "./utils/email/messageWorker.js";
dotenv.config();
const app = express();
app.use(
cors({
credentials: true,
})
);
app.use(express.json({ limit: "50mb" }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
const server = http.createServer(app);
app.use("/api", routes);
app.get("/", async (req, res) => {
res.send("hello world");
});
server.listen(process.env.PORT, async () => {
await connectToDB();
console.log(`Server running on http://localhost:${server.address().port}`);
await startWorker();
});