-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.ts
More file actions
36 lines (27 loc) · 712 Bytes
/
Copy pathapp.ts
File metadata and controls
36 lines (27 loc) · 712 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
// src/app.ts
import express from "express";
import routes from "./routes";
import dotenv from "dotenv";
import { connectDB } from "./db";
const cors = require('cors');
import bodyParser from "body-parser";
dotenv.config();
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use(express.json());
const PORT = process.env.PORT || 8000;
// SAY Hello
app.get("/", (req, res) => {
res.json({
message: "Welcome to Assistant API"
})
})
app.use(routes);
connectDB().then(() => {
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});
}).catch((error) => {
console.error("Failed to connect to the database:", error);
});