Skip to content

Commit d8cd876

Browse files
authored
Merge pull request #177 from Kong/fix-middleware-bug
fix bug in middleware
2 parents e32332a + c8406a7 commit d8cd876

File tree

5 files changed

+35
-27
lines changed

5 files changed

+35
-27
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Insomnia Mockbin is maintained by [Kong](https://github.com/Kong), who also main
1515
- [Running with Docker Compose](#running-with-docker-compose)
1616
- [Documentation](#documentation)
1717
- [API Docs](#api-docs)
18+
- [Releasing](#releasing)
1819
- [Software Bill of materials](#software-bill-of-materials)
1920
- [Verify a container image signature](#verify-a-container-image-signature)
2021
- [Verify a container image provenance](#verify-a-container-image-provenance)
@@ -77,6 +78,16 @@ docker compose up
7778

7879
Read the full API documentation, please review the [API Docs](https://github.com/Kong/mockbin/tree/master/docs).
7980

81+
## Releasing
82+
83+
Run the following command and push the newly created commit into your PR.
84+
This will bump commit and tag, you will need to push this to the remote, which trigger the release action upon merging the PR.
85+
86+
```sh
87+
npm version patch
88+
git push origin tag <tag_name>
89+
```
90+
8091
### Software Bill of materials
8192

8293
Kong Insomnia Mockbin produces SBOMs for the below categories:

lib/index.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ const routes = require("./routes");
66
module.exports = function (options) {
77
const router = express.Router();
88

9-
const defaults = [
10-
mw.errorHandler,
11-
mw.bodyParser,
12-
mw.cors,
13-
mw.poweredBy,
14-
mw.negotiateContent,
15-
];
16-
179
const endpoints = [
1810
{ action: "get", path: "/", route: routes.hello },
1911
{ action: "all", path: "/ip", route: routes.ips.one },
@@ -38,11 +30,18 @@ module.exports = function (options) {
3830
];
3931

4032
endpoints.forEach((endpoint) => {
41-
// add route to middleware
42-
defaults.splice(3, 1, endpoint.route);
43-
4433
// assign router to action at path
45-
router[endpoint.action].apply(router, [endpoint.path].concat(defaults));
34+
router[endpoint.action].apply(
35+
router,
36+
[endpoint.path].concat([
37+
mw.errorHandler,
38+
mw.bodyParser,
39+
endpoint.route,
40+
mw.cors,
41+
mw.poweredBy,
42+
mw.negotiateContent,
43+
]),
44+
);
4645
});
4746

4847
if (options?.redis) {

lib/routes/bins.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ module.exports = function bins(dsnStr) {
2929

3030
const router = express.Router();
3131

32-
const defaults = [
33-
mw.errorHandler,
34-
mw.bodyParser,
35-
null,
36-
mw.cors,
37-
mw.negotiateContent,
38-
];
39-
4032
const endpoints = [
4133
{ action: "get", path: "/create", route: routes.form },
4234
{
@@ -69,11 +61,17 @@ module.exports = function bins(dsnStr) {
6961
];
7062

7163
endpoints.forEach((endpoint) => {
72-
// add route to middleware
73-
defaults.splice(3, 1, endpoint.route);
74-
7564
// assign router to action at path
76-
router[endpoint.action].apply(router, [endpoint.path].concat(defaults));
65+
router[endpoint.action].apply(
66+
router,
67+
[endpoint.path].concat([
68+
mw.errorHandler,
69+
mw.bodyParser,
70+
endpoint.route,
71+
mw.cors,
72+
mw.negotiateContent,
73+
]),
74+
);
7775
});
7876

7977
return router;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.1",
2+
"version": "2.0.2",
33
"name": "mockbin",
44
"description": "Test, mock, and track HTTP requests & responses between libraries, sockets and APIs",
55
"author": "Kong (https://www.konghq.com/)",

0 commit comments

Comments
 (0)