-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
27 lines (19 loc) · 718 Bytes
/
Copy pathserver.js
File metadata and controls
27 lines (19 loc) · 718 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
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const makes = require('./routes/api/makes');
const models = require('./routes/api/models');
const app = express();
// Bodyparser Middleware
app.use(bodyParser.json());
// DB config
const db = require('./config/keys').mongoURI;
// Connect to DB
mongoose.connect(db, { useNewUrlParser: true, useCreateIndex: true })
.then(() => console.log('MongoDB Prijungta...'))
.catch(err => console.log(err));
//use routes
app.use('/api/makes', makes);
app.use('/api/models', models);
const port = process.env.PORT || 5000;
app.listen(port, () => console.log(`Serveris startavo ant ${port} porto`));