@increase21/simplenodejs 1.0.29 → 1.0.30

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/README.md CHANGED
@@ -271,7 +271,7 @@ Parses the request body. Must be registered before controllers access `this.body
271
271
  | Param | Type | Description |
272
272
  |---|---|---|
273
273
  | `limit` | `string \| number` | Max body size (e.g. `"2mb"`, `"500kb"`, or bytes as number). Default: `"1mb"` |
274
- | `ignoreStream` | `{url:string, method:string}[] \| (req) => boolean` | Skip stream reading and pass the raw stream to the handler for matching requests. Accepts a list of path prefixes and their http menthods or a predicate function. |
274
+ | `ignoreStream` | `{url:string, method:string, type: exact or prefex}[] \| (req) => boolean` | Skip stream reading and pass the raw stream to the handler for matching requests. Accepts a list of path prefixes and their http menthods or a predicate function. The `type` field determines whether the URL should be matched exactly (`exact`) or as a prefix (`prefix`) |
275
275
 
276
276
  ```ts
277
277
  app.use(SetBodyParser({ limit: "2mb" }));
@@ -11,10 +11,12 @@ export type SimpleJSBodyParseType = {
11
11
  * Skip stream reading (and pass the raw stream to the handler) for matching requests.
12
12
  * Accepts a list of path prefixes or a predicate function.
13
13
  * Multipart requests are always skipped regardless of this option.
14
+ * The `type` field determines whether the URL should be matched exactly (`exact`) or as a prefix (`prefix`).
14
15
  */
15
16
  ignoreStream?: {
16
17
  url: string;
17
18
  method: HttpMethod;
19
+ type: 'exact' | 'prefix';
18
20
  }[] | ((req: RequestObject) => boolean);
19
21
  };
20
22
  export interface SimpleJsControllerMeta {
@@ -193,7 +193,7 @@ function SetBodyParser(opts) {
193
193
  return opts.ignoreStream(req);
194
194
  const url = req.url || "";
195
195
  const method = (req.method || "").toLowerCase();
196
- return opts.ignoreStream.some(p => (url === p.url || url.startsWith(p.url)) && method === p.method);
196
+ return opts.ignoreStream.some(p => (p.type === "exact" ? url === p.url : url.startsWith(p.url)) && method === p.method);
197
197
  })();
198
198
  // For simplicity, we only parse JSON and plain text. Multipart/form-data and other types are ignored.
199
199
  if (shouldIgnoreStream)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@increase21/simplenodejs",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "description": "Lightweight Node.js HTTP framework with middlewares and plugins",
5
5
  "dev": "dist/index.js",
6
6
  "bugs": "https://github.com/increase21/simplenodejs/issues",