aboutsummaryrefslogtreecommitdiff
path: root/index.ts
blob: 6db89291340ec6f76453cd18b54d9e76972b982b (plain)
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
import app from './app';
import mongoose from 'mongoose';
import Promise from 'bluebird';

mongoose.Promise = 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 =>
  app.channel('everybody').join(connection)
);
// Publish all events to the `everybody` channel
app.publish(data => app.channel('everybody'));


const port = 3030
app.listen(port).on('listening', () =>
  console.log(`Feathers server listening on localhost:${port}`)
);