UNPKG

953 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.useGrab = useGrab;
7
8var _bodyParser = require('body-parser');
9
10var _bodyParser2 = _interopRequireDefault(_bodyParser);
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14function useGrab(app, config) {
15 // unpack
16 var email = config.email,
17 localAuthenticate = config.localAuthenticate,
18 jwtAuthenticate = config.jwtAuthenticate,
19 password = config.password,
20 routePath = config.routePath,
21 transactionsRouter = config.transactionsRouter;
22 // use
23
24 app.use(_bodyParser2.default.json()); // to support JSON-encoded bodies
25 // auth body
26 var authBody = { email: email,
27 isJwtNext: true,
28 password: password
29 // use
30 };app.use(routePath, function (req, res, next) {
31 Object.assign(req.body, authBody);
32 next();
33 }, localAuthenticate, jwtAuthenticate, transactionsRouter);
34}
\No newline at end of file