-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
29 lines (22 loc) · 674 Bytes
/
Copy pathserver.ts
File metadata and controls
29 lines (22 loc) · 674 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
import express from "express";
import dotenv from "dotenv";
import morgan from "morgan";
import { connectDB } from "./config/db";
import bootcamps from "./routes/bootcamps";
import { errorHandler } from "./middlewares/error";
dotenv.config({ path: `${__dirname}/config/config.env` });
const app = express();
app.use(express.json());
app.use(morgan("dev"));
app.use("/api/v1/bootcamps", bootcamps);
app.use(errorHandler);
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
try {
connectDB();
} catch (error: any) {
console.error(`Error: ${error.message}`);
process.exit(1);
}
console.log(`Server running in mode on port ${PORT}`);
});