-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
21 lines (17 loc) · 692 Bytes
/
index.js
File metadata and controls
21 lines (17 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import mongoose from 'mongoose';
import util from 'util';
import config from './config/config';
import app from './config/express';
const mongoUri = `${config.mongo.host}:${config.mongo.port}`;
mongoose.connect(mongoUri, { server: { socketOptions: { keepAlive: 1 } } });
mongoose.connection.on('error', () => {
throw new Error(`unable to connect to database: ${config.db}`);
});
mongoose.Promise = Promise;
mongoose.set('debug', (collectionName, method, query, doc) => {
console.log(`${collectionName}.${method}`, util.inspect(query, false, 20), doc);
});
app.listen(config.port, () => {
console.log(`server started on port ${config.port} (${config.env})`);
});
export default app;