-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (26 loc) · 761 Bytes
/
server.js
File metadata and controls
30 lines (26 loc) · 761 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
import express from "express";
import mongoose from "mongoose";
import userrouter from "./routes/user-routes";
import blogrouter from "./routes/blog-routes";
import queryrouter from "./routes/query-routes";
import cors from "cors";
import dotenv from "dotenv";
dotenv.config();
const app = express(); //app will use express fucntionality
app.use(
cors({
origin: "*",
})
);
app.use(express.json());
app.use("/api/user", userrouter);
app.use("/api/blog", blogrouter);
app.use("/api/query", queryrouter);
mongoose.set("strictQuery", true);
mongoose
.connect(
process.env.DATABASE
)
.then(() => app.listen(4000))
.then(() => console.log("connected to database port 4000 "))
.catch((err) => console.log(err));