Skip to content

Commit

Permalink
fix bug in
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkav committed Jul 1, 2024
1 parent e32332a commit 2653b4c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
12 changes: 8 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,15 @@ module.exports = function (options) {
];

endpoints.forEach((endpoint) => {
// add route to middleware
defaults.splice(3, 1, endpoint.route);

// assign router to action at path
router[endpoint.action].apply(router, [endpoint.path].concat(defaults));
router[endpoint.action].apply(router, [endpoint.path].concat([
mw.errorHandler,
mw.bodyParser,
endpoint.route,
mw.cors,
mw.poweredBy,
mw.negotiateContent,
]));
});

if (options?.redis) {
Expand Down
21 changes: 9 additions & 12 deletions lib/routes/bins.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ module.exports = function bins(dsnStr) {

const router = express.Router();

const defaults = [
mw.errorHandler,
mw.bodyParser,
null,
mw.cors,
mw.negotiateContent,
];

const endpoints = [
{ action: "get", path: "/create", route: routes.form },
{
Expand Down Expand Up @@ -69,11 +61,16 @@ module.exports = function bins(dsnStr) {
];

endpoints.forEach((endpoint) => {
// add route to middleware
defaults.splice(3, 1, endpoint.route);

// assign router to action at path
router[endpoint.action].apply(router, [endpoint.path].concat(defaults));
router[endpoint.action].apply(router, [endpoint.path].concat(
[
mw.errorHandler,
mw.bodyParser,
endpoint.route,
mw.cors,
mw.negotiateContent,
]
));
});

return router;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.1",
"version": "2.0.2",
"name": "mockbin",
"description": "Test, mock, and track HTTP requests & responses between libraries, sockets and APIs",
"author": "Kong (https://www.konghq.com/)",
Expand Down

0 comments on commit 2653b4c

Please sign in to comment.