Skip to content

Commit 87ff945

Browse files
committed
Move wares to ctx
1 parent 76cecc5 commit 87ff945

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

lib/api/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
'use strict';
22

3-
function create (env, ctx, wares) {
3+
function create (env, ctx) {
44
var _each = require('lodash/each')
55
, express = require('express')
66
, app = express( )
77
;
88

9+
const wares = ctx.wares;
10+
911
// set up express app with our options
1012
app.set('name', env.name);
1113
app.set('version', env.version);

lib/api/notifications-v2.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
var consts = require('../constants');
44

5-
function configure (app, ctx, wares) {
5+
function configure (app, ctx) {
66
var express = require('express')
77
, api = express.Router( )
88
;
99

10-
api.use(wares.compression());
11-
api.use(wares.rawParser);
12-
api.use(wares.bodyParser.json({
10+
api.use(ctx.wares.compression());
11+
api.use(ctx.wares.rawParser);
12+
api.use(ctx.wares.bodyParser.json({
1313
limit: '50Mb'
1414
}));
15-
api.use(wares.urlencodedParser);
15+
api.use(ctx.wares.urlencodedParser);
1616

1717
api.post('/loop', ctx.authorization.isPermitted('notifications:loop:push'), function (req, res) {
1818
ctx.loop.sendNotification(req.body, req.connection.remoteAddress, function (error) {

lib/server/app.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,10 @@ function create (env, ctx) {
183183
// api and json object variables
184184
///////////////////////////////////////////////////
185185
const apiRoot = require('../api/root')(env, ctx);
186-
var wares = require('../middleware/')(env);
187-
var api = require('../api/')(env, ctx, wares);
186+
var api = require('../api/')(env, ctx);
188187
var api3 = require('../api3/')(env, ctx);
189188
var ddata = require('../data/endpoints')(env, ctx);
190-
var notificationsV2 = require('../api/notifications-v2')(app, ctx, wares);
189+
var notificationsV2 = require('../api/notifications-v2')(app, ctx);
191190

192191
app.use(compression({
193192
filter: function shouldCompress (req, res) {

lib/server/bootevent.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ function boot (env, language) {
208208
, levels: ctx.levels
209209
}).registerServerDefaults();
210210

211+
ctx.wares = require('../middleware/')(env);
212+
211213
ctx.pushover = require('../plugins/pushover')(env, ctx);
212214
ctx.maker = require('../plugins/maker')(env);
213215
ctx.pushnotify = require('./pushnotify')(env, ctx);

0 commit comments

Comments
 (0)