forked from rasolofonirina/node-using-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (23 loc) · 698 Bytes
/
index.js
File metadata and controls
30 lines (23 loc) · 698 Bytes
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
import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import routes from './src/routes/routes';
const app = express();
const PORT = 1025;
//mongoose connection
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://localhost:27017/productsdb', {
useNewUrlParser: true,
useUnifiedTopology: true,
});
// bodyparser setup
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
// executing routes function with express app
routes(app);
app.get('/', (req, res) =>
res.send(`Store server running on port ${PORT}`)
);
app.listen(PORT, () =>
console.log(`Your server is running on port ${PORT}`)
);