-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
46 lines (37 loc) · 1.03 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
const express = require("express");
const app = express();
const cors = require("cors");
const mongoose = require("mongoose");
const userRoutes = require("./Routes/UserRoutes");
const postRoutes = require("./Routes/PostRoutes");
const formData = require("express-form-data");
const fileupload = require("express-fileupload");
app.use(fileupload());
// const bodyParser = require('body-parser')
// const multer = require('multer');
app.use(express.urlencoded());
// app.use(bodyParser.json());
app.use(cors());
app.use(express.json());
app.use(formData.parse());
var path = require('path');
app.use(express.static(path.join(__dirname, 'Routes')));
mongoose
.connect(
"mongodb://127.0.0.1:27017/pplDB",
{
useNewUrlParser: true,
useUnifiedTopology: true,
}
)
.then(() => {
console.log("connection done !!");
})
.catch((err) => {
console.log("Error ", err);
});
app.use("/user", userRoutes);
app.use("/post", postRoutes);
app.listen(3001, '192.168.43.28', function () {
console.log("Express server is running on 3001");
});