@uniflowed/router 0.0.0-alpha.20 → 0.0.0-alpha.22

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.
Files changed (2) hide show
  1. package/handler.js +13 -4
  2. package/package.json +3 -3
package/handler.js CHANGED
@@ -114,7 +114,16 @@ export type HandlerRecord = {|
114
114
  * taste: the `fetch` specification forbids the last two outright, so a handler
115
115
  * exporting either could never be reached by a browser.
116
116
  */
117
- const METHODS = ["GET", "HEAD", "QUERY", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"];
117
+ export const HANDLER_METHODS: $ReadOnlyArray<string> = Object.freeze([
118
+ "GET",
119
+ "HEAD",
120
+ "QUERY",
121
+ "POST",
122
+ "PUT",
123
+ "PATCH",
124
+ "DELETE",
125
+ "OPTIONS",
126
+ ]);
118
127
 
119
128
  /**
120
129
  * Match a request against the handler table and run it.
@@ -193,7 +202,7 @@ export function createDispatcher(options: {|
193
202
  * answer one.
194
203
  */
195
204
  function pick(module: HandlerModule, method: string): Handler | null {
196
- if (!METHODS.includes(method)) {
205
+ if (!HANDLER_METHODS.includes(method)) {
197
206
  return null;
198
207
  }
199
208
  const own = module[method];
@@ -213,7 +222,7 @@ function pick(module: HandlerModule, method: string): Handler | null {
213
222
  * do that here" from "there is nothing here".
214
223
  */
215
224
  function methodNotAllowed(module: HandlerModule): Response {
216
- const own = new Set(METHODS.filter((method) => typeof module[method] === "function"));
225
+ const own = new Set(HANDLER_METHODS.filter((method) => typeof module[method] === "function"));
217
226
  // A module exporting `GET` also answers `HEAD`, so `Allow` has to say so.
218
227
  if (own.has("GET")) {
219
228
  own.add("HEAD");
@@ -222,7 +231,7 @@ function methodNotAllowed(module: HandlerModule): Response {
222
231
  // header reads in the conventional order however the module was written.
223
232
  return new Response(null, {
224
233
  status: 405,
225
- headers: { allow: METHODS.filter((method) => own.has(method)).join(", ") },
234
+ headers: { allow: HANDLER_METHODS.filter((method) => own.has(method)).join(", ") },
226
235
  });
227
236
  }
228
237
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniflowed/router",
3
- "version": "0.0.0-alpha.20",
3
+ "version": "0.0.0-alpha.22",
4
4
  "description": "The file-system router for Flow React applications: matching, layouts, loaders, navigation, server rendering and hydration.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "react-dom": ">=19"
35
35
  },
36
36
  "dependencies": {
37
- "@uniflowed/hooks": "0.0.0-alpha.20",
38
- "@uniflowed/server": "0.0.0-alpha.20"
37
+ "@uniflowed/hooks": "0.0.0-alpha.22",
38
+ "@uniflowed/server": "0.0.0-alpha.22"
39
39
  }
40
40
  }