-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
36 lines (26 loc) · 960 Bytes
/
Copy pathserver.js
File metadata and controls
36 lines (26 loc) · 960 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
30
31
32
33
34
35
36
"use strict";
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const events = require('./routes/events');
const mongoose = require('mongoose');
//const dbController = require('./models/dbController');
const mongoURL = 'mongodb://localhost:27017/events-inc';
mongoose.connect(mongoURL);
mongoose.Promise = global.Promise;
let db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
app.use(bodyParser.json({ type: 'application/json' }));
app.listen(3000, () => console.log('App listening on port 3000!'));
app.get('/', (req, res) => res.send('Build a Backend with Node.js and Express.js'));
app.route("/events")
.get(events.findAll)
.post(events.add);
app.route("/events/:id")
.get(events.findById)
.put(events.updateById)
.delete(events.deleteById);
app.route("/event/find")
.post(events.find);
//dbController.helloDatabase();
module.exports = app;