-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
41 lines (29 loc) · 818 Bytes
/
App.js
File metadata and controls
41 lines (29 loc) · 818 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
37
38
39
40
41
/**
* Created by john on 14/10/17.
*/
var express = require('express');
var app = express();
var path = require('path');
var mongoose = require('mongoose');
// after the '/' what the db is called
var dbUrl = 'mongodb://localhost/toDoDB';
mongoose.connect(dbUrl, function (err) {
if(err){
console.log('Not connected to mongoose:', err);
}else{
console.log('Connected to mongoose:', dbUrl);
}
});
var routes = require('./routes/index.js');
// gets the router from the file
app.use('/', routes);
var api = require('./routes/api');
app.use('/api', api);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hjs');
// port the app is listing on
app.listen(8090, function () {
console.log('Listening on 8090');
});
module.exports = app;