Skip to content

Commit a4e8466

Browse files
authored
Merge pull request #7144 from nightscout/add_wares_to_v2
Add wares to v2 to support request parsing
2 parents 027bf5e + 87ff945 commit a4e8466

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/api/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function create (env, ctx) {
66
, app = express( )
77
;
88

9-
var wares = require('../middleware/')(env);
9+
const wares = ctx.wares;
1010

1111
// set up express app with our options
1212
app.set('name', env.name);

lib/api/notifications-v2.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ function configure (app, ctx) {
77
, api = express.Router( )
88
;
99

10+
api.use(ctx.wares.compression());
11+
api.use(ctx.wares.rawParser);
12+
api.use(ctx.wares.bodyParser.json({
13+
limit: '50Mb'
14+
}));
15+
api.use(ctx.wares.urlencodedParser);
16+
1017
api.post('/loop', ctx.authorization.isPermitted('notifications:loop:push'), function (req, res) {
1118
ctx.loop.sendNotification(req.body, req.connection.remoteAddress, function (error) {
1219
if (error) {

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)