diff options
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 30 |
1 files changed, 6 insertions, 24 deletions
@@ -1,30 +1,12 @@ -const mongoose = require('mongoose'); -const Promise = require('bluebird'); require('dotenv').config(); -const app = require('./app.js'); - -mongoose.Promise = Promise; +const app = require('./src/app.js'); +const { connectDb } = require('./src/connectDb.js'); const PORT = process.env.PORT || 3030; -const MONGODB_URL = process.env.MONGODB_URI || 'mongodb://localhost:27017/bsu-fantom'; -const { MONGODB_USER, MONGODB_PASSWORD } = process.env; - -mongoose.connect(MONGODB_URL, { - user: MONGODB_USER, - pass: MONGODB_PASSWORD, - useNewUrlParser: true, - useUnifiedTopology: true, - useCreateIndex: true, - useFindAndModify: false, - family: 4 // Use IPv4, skip trying IPv6 -}); - -const db = mongoose.connection; -db.on('error', console.error.bind(console, 'connection error:')); -db.once('open', () => { - console.log('Connection to MongoDB successful'); -}); -app.listen(PORT).on('listening', () => console.log(`Feathers server listening on localhost:${PORT}`)); +connectDb().then(() => app + .listen(PORT) + .on('listening', () => console.log(`Feathers server listening on localhost:${PORT}`)) +); |