-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
25 lines (19 loc) · 781 Bytes
/
app.js
File metadata and controls
25 lines (19 loc) · 781 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
const express = require('express');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const cors = require('cors');
const logger = require('./utils/logger');
const subscriptions = require('./routes/subscriptions');
const push = require('./routes/push');
module.exports = (config) => {
const app = new express();
app.use(morgan(':method :url :status :response-time ms - :res[content-length]', {
stream: logger.stream
}));
app.use(bodyParser.json());
app.use(cors());
app.use('/subscriptions', subscriptions( config.subscriptionsDBConfig ));
app.use('/push', push( config.pushManagerConfig ));
app.listen(config.apiConfig.port, function() { console.log(`Push api server is now listening on port ${config.apiConfig.port}`) })
return app;
}