-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (27 loc) · 772 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
37
const dotenv = require("dotenv");
dotenv.config({ path: ".env" });
require("./db/db.connect");
const express = require("express");
const cors = require("cors");
const helmet = require("helmet");
const taskRouter = require("./routes/task.routes");
const app = express();
app.use(
cors()
);
app.use(helmet());
app.use(express.json());
app.use("/tasks", taskRouter);
app.use((err, req, res, next) => {
console.error(err.stack);
res.status(500).json({ error: "Something went wrong!" });
});
app.use((req, res) => {
res.status(404).json({ error: "Route not found" });
});
app.get("/", (req, res) => {
res.send("Welcome to Organizely's Express app!");
});
app.listen(process.env.PORT, () => {
console.log(`server started on port ${process.env.PORT}`);
});