-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
33 lines (29 loc) · 837 Bytes
/
server.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
require("dotenv").config();
const express = require("express");
const app = express();
const cors = require("cors");
const userRoute = require("./routes/users");
const authRoute = require("./routes/auth");
const postRoute = require("./routes/posts");
const PORT = 8000 || "https://japanada-backend.onrender.com";
const mongoose = require("mongoose");
require("dotenv").config();
//connecting DB
mongoose
.connect(process.env.MONGOURL)
.then(() => {
console.log("connecting DB... ");
})
.catch((err) => {
console.log(err);
});
//middle
app.use(cors());
app.use(express.json());
app.use("/api/users", userRoute);
app.use("/api/auth", authRoute);
app.use("/api/posts", postRoute);
app.get("/", (req, res) => {
res.send("your JAPANADA server is running!");
});
app.listen(PORT, () => console.log(`server is running ${PORT}`));