Skip to content

Commit 5235198

Browse files
committed
always use subdomain rewrite
1 parent 7fa5515 commit 5235198

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

lib/routes/bins.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,24 @@ module.exports = function bins(dsnStr) {
5757
},
5858
{
5959
action: "get",
60-
path: "/log/:uuid*",
60+
path: ":serviceid/log/:custompath*",
6161
route: routes.log(client),
6262
},
6363
{
6464
action: "delete",
65-
path: "/delete/:uuid*",
65+
path: ":serviceid/delete/:custompath*",
6666
route: routes.delete(client),
6767
},
68-
{ action: "put", path: "/upsert/:uuid*", route: routes.update(client) },
69-
{ action: "all", path: "/:uuid*", route: routes.run(client) },
68+
{
69+
action: "put",
70+
path: ":serviceid/upsert/:custompath*",
71+
route: routes.update(client),
72+
},
73+
{
74+
action: "all",
75+
path: "/:serviceid/:custompath*",
76+
route: routes.run(client),
77+
},
7078
];
7179

7280
endpoints.forEach((endpoint) => {

lib/routes/bins/delete.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const debug = require("debug")("mockbin");
22

33
module.exports = (client) => (req, res, next) => {
4-
const compoundId = req.params.uuid + req.params[0];
4+
const compoundId = req.params.serviceid + req.params.custompath;
55
client.del(`bin:${compoundId}`, (err) => {
66
if (err) {
77
debug(err);

lib/routes/bins/log.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const pkg = require("../../../package.json");
33

44
module.exports = (client) => (req, res, next) => {
55
res.view = "bin/log";
6-
const compoundId = req.params.uuid + req.params[0];
6+
const compoundId = req.params.serviceid + req.params.custompath;
77
client.lrange(`log:${compoundId}`, 0, -1, (err, history) => {
88
if (err) {
99
debug(err);

lib/routes/bins/run.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const debug = require("debug")("mockbin");
22

33
module.exports = (client) => (req, res, next) => {
44
// compoundId allows us to provide paths in the id to resolve to a specific bin
5-
const compoundId = req.params.uuid + req.params[0];
5+
const compoundId = req.params.serviceid + req.params.custompath;
66
client.get(`bin:${compoundId}`, function (err, value) {
77
if (err) {
88
debug(err);

lib/routes/bins/update.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ const validate = require("har-validator");
44
const path = require("node:path");
55

66
module.exports = (client) => (req, res, next) => {
7-
const id = req.params.uuid;
8-
const path = req.params[0];
9-
const compoundId = id + path;
7+
const compoundId = req.params.serviceid + req.params.custompath;
108

119
let mock = req.jsonBody;
1210

0 commit comments

Comments
 (0)