@tahminator/sapling 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,9 +42,14 @@ export function Controller({ prefix = "", deps = [] } = {
42
42
  if (typeof fn !== "function")
43
43
  continue;
44
44
  const fp = prefix + path;
45
- if (usedPaths.has(fp)) {
45
+ // Only check for duplicates on non-middleware routes
46
+ // Middleware (USE) can have duplicate paths
47
+ if (method !== "USE" && usedPaths.has(fp)) {
46
48
  throw new Error(`Duplicate route path "${fp}" detected in controller "${target.name}"`);
47
49
  }
50
+ if (method !== "USE") {
51
+ usedPaths.add(fp);
52
+ }
48
53
  const methodName = methodResolve[method];
49
54
  router[methodName](fp, (request, response, next) => __awaiter(this, void 0, void 0, function* () {
50
55
  const result = yield fn.bind(controllerInstance)(request, response, next);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tahminator/sapling",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "A library to help you write cleaner Express.js code",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",