@staff0rd/assist 0.172.4 → 0.173.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.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.172.4",
9
+ version: "0.173.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -76,6 +76,7 @@ var package_default = {
76
76
  marked: "^15.0.12",
77
77
  react: "^19.2.4",
78
78
  "react-dom": "^19.2.4",
79
+ "react-router": "^7.14.0",
79
80
  "semantic-release": "^25.0.2",
80
81
  tsup: "^8.5.1",
81
82
  vitest: "^4.0.18"
@@ -1379,18 +1380,28 @@ var itemRoutes = {
1379
1380
  PATCH: (req, res, id) => patchItemStatus(req, res, id),
1380
1381
  DELETE: (_req, res, id) => deleteItem2(res, id)
1381
1382
  };
1383
+ var serveHtml = createHtmlHandler(getHtml);
1382
1384
  var baseHandler = createRouteHandler(routes);
1385
+ async function handleItemRoute(req, res, pathname) {
1386
+ const match = pathname.match(/^\/api\/items\/(\d+)$/);
1387
+ if (!match) return false;
1388
+ const handler = itemRoutes[req.method ?? "GET"];
1389
+ if (!handler) return false;
1390
+ await handler(req, res, Number.parseInt(match[1], 10));
1391
+ return true;
1392
+ }
1383
1393
  async function handleRequest(req, res, port) {
1384
1394
  const url = new URL(req.url ?? "/", `http://localhost:${port}`);
1385
1395
  const method = req.method ?? "GET";
1386
1396
  const pathname = url.pathname;
1387
- const itemMatch = pathname.match(/^\/api\/items\/(\d+)$/);
1388
- if (itemMatch) {
1389
- const itemHandler = itemRoutes[method];
1390
- if (itemHandler) {
1391
- await itemHandler(req, res, Number.parseInt(itemMatch[1], 10));
1392
- return;
1393
- }
1397
+ if (await handleItemRoute(req, res, pathname)) return;
1398
+ if (routes[`${method} ${pathname}`]) {
1399
+ await baseHandler(req, res, port);
1400
+ return;
1401
+ }
1402
+ if (method === "GET" && !pathname.startsWith("/api/")) {
1403
+ await serveHtml(req, res);
1404
+ return;
1394
1405
  }
1395
1406
  await baseHandler(req, res, port);
1396
1407
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.172.4",
3
+ "version": "0.173.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -70,6 +70,7 @@
70
70
  "marked": "^15.0.12",
71
71
  "react": "^19.2.4",
72
72
  "react-dom": "^19.2.4",
73
+ "react-router": "^7.14.0",
73
74
  "semantic-release": "^25.0.2",
74
75
  "tsup": "^8.5.1",
75
76
  "vitest": "^4.0.18"