-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (26 loc) · 776 Bytes
/
app.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
const express = require("express");
const app = express();
const helmet = require("helmet");
const morgan = require("morgan");
const mongoose = require("mongoose");
const env = require("dotenv").config();
const MONGODB_URI = process.env.Uri;
app.use(express.json());
app.use(helmet());
app.use(morgan("common"));
const userpostRouter = require("./routes/userpost");
const userDetails = require("./models/user");
const authRouter = require("./routes/auth");
app.use("/api/auth", authRouter);
app.use("/api/posts", userpostRouter);
const userRoute = require("./routes/users");
app.use("/api/users", userRoute);
mongoose
.connect(MONGODB_URI)
.then((result) => {
console.log("db connected");
app.listen(3000);
})
.catch((err) => {
console.log(err);
});