mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Move wares to ctx
This commit is contained in:
+3
-1
@@ -1,11 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function create (env, ctx, wares) {
|
function create (env, ctx) {
|
||||||
var _each = require('lodash/each')
|
var _each = require('lodash/each')
|
||||||
, express = require('express')
|
, express = require('express')
|
||||||
, app = express( )
|
, app = express( )
|
||||||
;
|
;
|
||||||
|
|
||||||
|
const wares = ctx.wares;
|
||||||
|
|
||||||
// set up express app with our options
|
// set up express app with our options
|
||||||
app.set('name', env.name);
|
app.set('name', env.name);
|
||||||
app.set('version', env.version);
|
app.set('version', env.version);
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
var consts = require('../constants');
|
var consts = require('../constants');
|
||||||
|
|
||||||
function configure (app, ctx, wares) {
|
function configure (app, ctx) {
|
||||||
var express = require('express')
|
var express = require('express')
|
||||||
, api = express.Router( )
|
, api = express.Router( )
|
||||||
;
|
;
|
||||||
|
|
||||||
api.use(wares.compression());
|
api.use(ctx.wares.compression());
|
||||||
api.use(wares.rawParser);
|
api.use(ctx.wares.rawParser);
|
||||||
api.use(wares.bodyParser.json({
|
api.use(ctx.wares.bodyParser.json({
|
||||||
limit: '50Mb'
|
limit: '50Mb'
|
||||||
}));
|
}));
|
||||||
api.use(wares.urlencodedParser);
|
api.use(ctx.wares.urlencodedParser);
|
||||||
|
|
||||||
api.post('/loop', ctx.authorization.isPermitted('notifications:loop:push'), function (req, res) {
|
api.post('/loop', ctx.authorization.isPermitted('notifications:loop:push'), function (req, res) {
|
||||||
ctx.loop.sendNotification(req.body, req.connection.remoteAddress, function (error) {
|
ctx.loop.sendNotification(req.body, req.connection.remoteAddress, function (error) {
|
||||||
|
|||||||
+2
-3
@@ -183,11 +183,10 @@ function create (env, ctx) {
|
|||||||
// api and json object variables
|
// api and json object variables
|
||||||
///////////////////////////////////////////////////
|
///////////////////////////////////////////////////
|
||||||
const apiRoot = require('../api/root')(env, ctx);
|
const apiRoot = require('../api/root')(env, ctx);
|
||||||
var wares = require('../middleware/')(env);
|
var api = require('../api/')(env, ctx);
|
||||||
var api = require('../api/')(env, ctx, wares);
|
|
||||||
var api3 = require('../api3/')(env, ctx);
|
var api3 = require('../api3/')(env, ctx);
|
||||||
var ddata = require('../data/endpoints')(env, ctx);
|
var ddata = require('../data/endpoints')(env, ctx);
|
||||||
var notificationsV2 = require('../api/notifications-v2')(app, ctx, wares);
|
var notificationsV2 = require('../api/notifications-v2')(app, ctx);
|
||||||
|
|
||||||
app.use(compression({
|
app.use(compression({
|
||||||
filter: function shouldCompress (req, res) {
|
filter: function shouldCompress (req, res) {
|
||||||
|
|||||||
@@ -208,6 +208,8 @@ function boot (env, language) {
|
|||||||
, levels: ctx.levels
|
, levels: ctx.levels
|
||||||
}).registerServerDefaults();
|
}).registerServerDefaults();
|
||||||
|
|
||||||
|
ctx.wares = require('../middleware/')(env);
|
||||||
|
|
||||||
ctx.pushover = require('../plugins/pushover')(env, ctx);
|
ctx.pushover = require('../plugins/pushover')(env, ctx);
|
||||||
ctx.maker = require('../plugins/maker')(env);
|
ctx.maker = require('../plugins/maker')(env);
|
||||||
ctx.pushnotify = require('./pushnotify')(env, ctx);
|
ctx.pushnotify = require('./pushnotify')(env, ctx);
|
||||||
|
|||||||
Reference in New Issue
Block a user