revojs 0.1.17 → 0.1.18

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.d.ts CHANGED
@@ -147,7 +147,7 @@ declare function sendRedirect(scope: Scope, path: string, config?: Mergeable<Res
147
147
  declare function sendBadRequest(scope: Scope, text: string, config?: Mergeable<ResponseConfig>): Response;
148
148
  declare function sendUnauthorized(scope: Scope, config?: Mergeable<ResponseConfig>): Response;
149
149
  declare function mimeType(file: string): MimeType;
150
- declare function toRoutePath(path: string): [string, string | undefined];
150
+ declare function toRoutePath(path: string): [string, ...Array<string>];
151
151
  declare function invoke(scope: Scope, pipeline: Array<Middleware>, index?: number): Promise<Result>;
152
152
  declare function createServer(): Promise<Server>;
153
153
  declare const ROUTER_CONTEXT: Descriptor<RouterContext>;
package/dist/index.js CHANGED
@@ -210,8 +210,9 @@ function mimeType(file) {
210
210
  return mimeTypes[extension ?? ""] ?? "text/plain";
211
211
  }
212
212
  function toRoutePath(path) {
213
- const result = ("/" + path).replaceAll(/\/index/g, "").replaceAll(/\[\.\.\.(.*?)\]/g, (_, value) => WILDCARD + value).replaceAll(/\[(.*?)\]/g, (_, value) => PARAMETER + value);
214
- return (result.startsWith("/") ? result : "/" + result).split(".");
213
+ const result = ("/" + path).replaceAll(/\[\.\.\.(.*?)\]/g, (_, value) => WILDCARD + value).replaceAll(/\[(.*?)\]/g, (_, value) => PARAMETER + value).split("/");
214
+ const properties = result.pop()?.toUpperCase().split(".") ?? [];
215
+ return [result.join("/"), ...properties];
215
216
  }
216
217
  async function invoke(scope, pipeline, index = 0) {
217
218
  return await pipeline.at(index)?.fetch(scope, async () => await invoke(scope, pipeline, index + 1));
@@ -373,7 +374,7 @@ function createApp(inputConfig) {
373
374
  resolve: (path) => path + "?raw"
374
375
  },
375
376
  routes: {
376
- match: "**/*.{js,ts}",
377
+ match: "**/{get,head,post,put,delete,connect,options,trace,patch}.{js,ts}",
377
378
  entries: ["./routes"]
378
379
  },
379
380
  exceptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revojs",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "type": "module",
5
5
  "repository": "coverbase/revojs",
6
6
  "license": "MIT",