-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (33 loc) · 903 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
31
32
33
34
35
36
37
38
39
40
41
// Imports
const express = require("express");
const cors = require("cors");
const mongoose = require("mongoose");
const app = express();
const authRoutes = require("./routes/auth");
// Middlewares
app.enable("trust proxy")
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
// Routes Prefix
app.use("/api/user/", authRoutes);
const PORT = process.env.PORT || 3000;
const {
MONGO_USER,
MONGO_PASSWORD,
MONGO_IP,
MONGO_PORT,
} = require("./configs/config");
app.use("/api", (req, res, next) => {
res.send("<h2> Hello there!</h2>");
console.log("Yeah, Its working")
});
mongoose
.connect(
`mongodb://${MONGO_USER}:${MONGO_PASSWORD}@${MONGO_IP}:${MONGO_PORT}/?authSource=admin`
)
.then(() => console.log("Db is running"))
.catch((e) => console.log(e));
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});