-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
37 lines (31 loc) · 1.11 KB
/
server.js
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
31
32
33
34
35
36
37
const config = require('config');
const feathers = require('feathers');
const rest = require('feathers-rest');
const socketio = require('feathers-socketio');
const hooks = require('feathers-hooks');
const bodyParser = require('body-parser');
const compression = require('compression');
const errorHandler = require('feathers-errors/handler');
const path = require('path');
const authentication = require('./server/services/authentication');
const services = require('./server/services');
const db = require('./server/db');
const app = feathers();
const dbPromise = db();
const servicesPromise = services(app, dbPromise);
app.use(compression());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(errorHandler());
app.use(feathers.static('public'));
app.configure(hooks());
app.configure(rest());
app.configure(socketio());
app.configure(authentication(app));
app.get('/*', (req,res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'))
});
Promise.all([dbPromise, servicesPromise]).then(
() => app.listen(config.port),
err => console.log('Failed to start: ', err)
);