From de9771959850f193f173616b73099c3ae6f010c9 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Tue, 9 Jun 2020 19:23:44 +0300 Subject: feat!: integrate mongoDB --- index.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'index.ts') diff --git a/index.ts b/index.ts index 35d1411..b358fdb 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,16 @@ import app from './app'; +import mongoose from 'mongoose'; + + +mongoose.Promise = global.Promise; + +mongoose.connect('mongodb://localhost:27017/which', { useNewUrlParser: true }); + +const db = mongoose.connection; +db.on('error', console.error.bind(console, 'connection error:')); +db.once('open', function() { + console.log('Connection to MongoDB successful'); +}); // Add any new real-time connection to the `everybody` channel app.on('connection', connection => @@ -8,7 +20,8 @@ app.on('connection', connection => app.publish(data => app.channel('everybody')); -app.listen(3030).on('listening', () => - console.log('Feathers server listening on localhost:3030') +const port = 3030 +app.listen(port).on('listening', () => + console.log(`Feathers server listening on localhost:${port}`) ); -- cgit v1.2.3