-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
26 lines (18 loc) · 668 Bytes
/
app.js
File metadata and controls
26 lines (18 loc) · 668 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
var express = require('express');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
mongoose.Promise = global.Promise;
var db = mongoose.connect('mongodb://aw101:html5js@ds011331.mlab.com:11331/aw101');
var Book = require('./models/bookModel');
var app = express();
var port = process.env.PORT || 3000;
app.use(bodyParser.urlencoded({ extended : true }));
app.use(bodyParser.json());
bookRouter = require('./routes/bookRoutes')(Book);
app.use('/api/books', bookRouter);
app.get('/', function(req, res) {
res.send('Welcome to my api');
});
app.listen(port, function() {
console.log("Running on http://localhost:" + port);
});