dn-react-router-toolkit 0.9.5 → 0.9.6

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.
package/dist/api/index.js CHANGED
@@ -490,30 +490,33 @@ function resourceHandler({
490
490
  });
491
491
  }
492
492
  const pathname = new URL(request.url).pathname;
493
- const itemId = pathname.split("/").filter(Boolean).at(-1);
494
- if (itemId) {
495
- const existing = await repository.find(itemId);
496
- if (!existing) {
497
- return (0, import_gw_response4.httpNotFound)();
498
- }
499
- if (isOwnedBy && (!auth || !isOwnedBy(auth, existing))) {
500
- return (0, import_gw_response4.httpForbidden)();
501
- }
502
- switch (request.method) {
503
- case "PATCH": {
504
- const handler = patchResourceHandler({
505
- repository,
506
- validators,
507
- primaryKey
508
- });
509
- return handler(existing, request);
493
+ const segments = pathname.split("/").filter(Boolean);
494
+ if (segments.length === 3) {
495
+ const itemId = segments.at(-1);
496
+ if (itemId) {
497
+ const existing = await repository.find(itemId);
498
+ if (!existing) {
499
+ return (0, import_gw_response4.httpNotFound)();
510
500
  }
511
- case "DELETE": {
512
- await repository.delete(itemId);
513
- return (0, import_gw_response4.httpNoContent)();
501
+ if (isOwnedBy && (!auth || !isOwnedBy(auth, existing))) {
502
+ return (0, import_gw_response4.httpForbidden)();
514
503
  }
515
- default: {
516
- return (0, import_gw_response4.httpMethodNotAllowed)();
504
+ switch (request.method) {
505
+ case "PATCH": {
506
+ const handler = patchResourceHandler({
507
+ repository,
508
+ validators,
509
+ primaryKey
510
+ });
511
+ return handler(existing, request);
512
+ }
513
+ case "DELETE": {
514
+ await repository.delete(itemId);
515
+ return (0, import_gw_response4.httpNoContent)();
516
+ }
517
+ default: {
518
+ return (0, import_gw_response4.httpMethodNotAllowed)();
519
+ }
517
520
  }
518
521
  }
519
522
  }
@@ -486,30 +486,33 @@ function resourceHandler({
486
486
  });
487
487
  }
488
488
  const pathname = new URL(request.url).pathname;
489
- const itemId = pathname.split("/").filter(Boolean).at(-1);
490
- if (itemId) {
491
- const existing = await repository.find(itemId);
492
- if (!existing) {
493
- return httpNotFound3();
494
- }
495
- if (isOwnedBy && (!auth || !isOwnedBy(auth, existing))) {
496
- return httpForbidden2();
497
- }
498
- switch (request.method) {
499
- case "PATCH": {
500
- const handler = patchResourceHandler({
501
- repository,
502
- validators,
503
- primaryKey
504
- });
505
- return handler(existing, request);
489
+ const segments = pathname.split("/").filter(Boolean);
490
+ if (segments.length === 3) {
491
+ const itemId = segments.at(-1);
492
+ if (itemId) {
493
+ const existing = await repository.find(itemId);
494
+ if (!existing) {
495
+ return httpNotFound3();
506
496
  }
507
- case "DELETE": {
508
- await repository.delete(itemId);
509
- return httpNoContent();
497
+ if (isOwnedBy && (!auth || !isOwnedBy(auth, existing))) {
498
+ return httpForbidden2();
510
499
  }
511
- default: {
512
- return httpMethodNotAllowed();
500
+ switch (request.method) {
501
+ case "PATCH": {
502
+ const handler = patchResourceHandler({
503
+ repository,
504
+ validators,
505
+ primaryKey
506
+ });
507
+ return handler(existing, request);
508
+ }
509
+ case "DELETE": {
510
+ await repository.delete(itemId);
511
+ return httpNoContent();
512
+ }
513
+ default: {
514
+ return httpMethodNotAllowed();
515
+ }
513
516
  }
514
517
  }
515
518
  }
@@ -268,30 +268,33 @@ function resourceHandler({
268
268
  });
269
269
  }
270
270
  const pathname = new URL(request.url).pathname;
271
- const itemId = pathname.split("/").filter(Boolean).at(-1);
272
- if (itemId) {
273
- const existing = await repository.find(itemId);
274
- if (!existing) {
275
- return (0, import_gw_response3.httpNotFound)();
276
- }
277
- if (isOwnedBy && (!auth || !isOwnedBy(auth, existing))) {
278
- return (0, import_gw_response3.httpForbidden)();
279
- }
280
- switch (request.method) {
281
- case "PATCH": {
282
- const handler = patchResourceHandler({
283
- repository,
284
- validators,
285
- primaryKey
286
- });
287
- return handler(existing, request);
271
+ const segments = pathname.split("/").filter(Boolean);
272
+ if (segments.length === 3) {
273
+ const itemId = segments.at(-1);
274
+ if (itemId) {
275
+ const existing = await repository.find(itemId);
276
+ if (!existing) {
277
+ return (0, import_gw_response3.httpNotFound)();
288
278
  }
289
- case "DELETE": {
290
- await repository.delete(itemId);
291
- return (0, import_gw_response3.httpNoContent)();
279
+ if (isOwnedBy && (!auth || !isOwnedBy(auth, existing))) {
280
+ return (0, import_gw_response3.httpForbidden)();
292
281
  }
293
- default: {
294
- return (0, import_gw_response3.httpMethodNotAllowed)();
282
+ switch (request.method) {
283
+ case "PATCH": {
284
+ const handler = patchResourceHandler({
285
+ repository,
286
+ validators,
287
+ primaryKey
288
+ });
289
+ return handler(existing, request);
290
+ }
291
+ case "DELETE": {
292
+ await repository.delete(itemId);
293
+ return (0, import_gw_response3.httpNoContent)();
294
+ }
295
+ default: {
296
+ return (0, import_gw_response3.httpMethodNotAllowed)();
297
+ }
295
298
  }
296
299
  }
297
300
  }
@@ -254,30 +254,33 @@ function resourceHandler({
254
254
  });
255
255
  }
256
256
  const pathname = new URL(request.url).pathname;
257
- const itemId = pathname.split("/").filter(Boolean).at(-1);
258
- if (itemId) {
259
- const existing = await repository.find(itemId);
260
- if (!existing) {
261
- return httpNotFound2();
262
- }
263
- if (isOwnedBy && (!auth || !isOwnedBy(auth, existing))) {
264
- return httpForbidden2();
265
- }
266
- switch (request.method) {
267
- case "PATCH": {
268
- const handler = patchResourceHandler({
269
- repository,
270
- validators,
271
- primaryKey
272
- });
273
- return handler(existing, request);
257
+ const segments = pathname.split("/").filter(Boolean);
258
+ if (segments.length === 3) {
259
+ const itemId = segments.at(-1);
260
+ if (itemId) {
261
+ const existing = await repository.find(itemId);
262
+ if (!existing) {
263
+ return httpNotFound2();
274
264
  }
275
- case "DELETE": {
276
- await repository.delete(itemId);
277
- return httpNoContent();
265
+ if (isOwnedBy && (!auth || !isOwnedBy(auth, existing))) {
266
+ return httpForbidden2();
278
267
  }
279
- default: {
280
- return httpMethodNotAllowed();
268
+ switch (request.method) {
269
+ case "PATCH": {
270
+ const handler = patchResourceHandler({
271
+ repository,
272
+ validators,
273
+ primaryKey
274
+ });
275
+ return handler(existing, request);
276
+ }
277
+ case "DELETE": {
278
+ await repository.delete(itemId);
279
+ return httpNoContent();
280
+ }
281
+ default: {
282
+ return httpMethodNotAllowed();
283
+ }
281
284
  }
282
285
  }
283
286
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dn-react-router-toolkit",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.js",