forked from mounicasruthi/Webkriti-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (29 loc) · 812 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
require("dotenv").config();
const express = require("express");
const cors = require("cors");
const bodyParser = require("body-parser");
const authRoutes = require("./routes/auth");
const postRoutes = require("./routes/posts");
const client = require("./configs/db");
const cloudinary = require("./configs/cloudinary");
const fs = require("fs");
const app = express();
app.use(express.json());
app.use(cors());
const port = process.env.PORT || 8000;
client.connect((err) => {
if (err) {
console.log(err);
}
else {
console.log("Connected to database");
}
});
app.get("/", (req, res) => {
res.status(200).send(`Server is up and running`);
});
app.use("/auth", authRoutes);
app.use("/posts", postRoutes);
app.listen(port, () => {
console.log(`Server is running on port: ${port}`);
});