-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
25 lines (21 loc) · 723 Bytes
/
app.js
File metadata and controls
25 lines (21 loc) · 723 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
const express = require('express');
const config = require('./src/config/config');
const glob = require('glob');
const mongoose = require('mongoose');
const bluebird = require('bluebird');
mongoose.connect(config.db, { useMongoClient: true });
mongoose.Promise = bluebird;
const db = mongoose.connection;
db.on('error', () => {
console.log(config);
throw new Error('Unable to connect to database at ' + config.db);
});
const models = glob.sync(config.root + './app/models/*.js');
models.forEach(function (model) {
require(model);
});
const app = require('./src/config/express')(express(), config);
module.exports = app;
app.listen(config.port, () => {
console.log('Magic happening on port ' + config.port);
});