forked from Elkfox/shopify-node-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.js
More file actions
30 lines (24 loc) · 829 Bytes
/
Copy pathstart.js
File metadata and controls
30 lines (24 loc) · 829 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
// start.js
const mongoose = require('mongoose');
const throng = require('throng');
require('dotenv').config({ path: '.env' });
mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost/purchaseOrders', {
useMongoClient: true,
});
mongoose.Promise = require('bluebird');
mongoose.connection.on('error', (err) => {
console.error(`🚫 Database Error 🚫 → ${err}`);
});
function start() {
/* You should require your models here so you don't have to initialise them all the time in
different controlers*/
require('./models/Shop');
const app = require('./app');
app.set('port', process.env.PORT || 7777);
const server = app.listen(app.get('port'), () => {
console.log(`Express running → PORT ${server.address().port}`);
});
}
throng({
workers: process.env.WEB_CONCURRENCY || 1,
}, start);