@sourceregistry/node-webserver 1.5.0 → 1.6.1
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 +45 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +178 -77
- package/dist/index.es.js.map +1 -1
- package/dist/middlewares/ratelimiter/SlidingWindow.d.ts +16 -0
- package/dist/middlewares/ratelimiter/index.d.ts +15 -0
- package/dist/types/router.d.ts +2 -0
- package/package.json +11 -8
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RateLimitStore } from './storage';
|
|
2
|
+
export declare class SlidingWindowStore implements RateLimitStore {
|
|
3
|
+
private readonly windowMs;
|
|
4
|
+
private data;
|
|
5
|
+
private cleanupInterval?;
|
|
6
|
+
constructor(opts: {
|
|
7
|
+
windowMs: number;
|
|
8
|
+
});
|
|
9
|
+
incr(key: string): Promise<{
|
|
10
|
+
current: number;
|
|
11
|
+
reset: number;
|
|
12
|
+
}>;
|
|
13
|
+
private startCleanup;
|
|
14
|
+
stop(): void;
|
|
15
|
+
resetAll(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { RateLimitStore } from './storage';
|
|
2
2
|
import { Middleware, RequestEvent } from '../../types';
|
|
3
|
+
import { MemoryStore } from './InMemory';
|
|
4
|
+
import { SlidingWindowStore } from './SlidingWindow';
|
|
3
5
|
export type Options = {
|
|
4
6
|
/**
|
|
5
7
|
* Window duration in milliseconds
|
|
@@ -37,6 +39,9 @@ export type Options = {
|
|
|
37
39
|
current: number;
|
|
38
40
|
max: number;
|
|
39
41
|
key: string;
|
|
42
|
+
reset: number;
|
|
43
|
+
remaining: number;
|
|
44
|
+
resetTimeMs: number;
|
|
40
45
|
}) => void;
|
|
41
46
|
/**
|
|
42
47
|
* Storage backend
|
|
@@ -44,6 +49,16 @@ export type Options = {
|
|
|
44
49
|
*/
|
|
45
50
|
store?: RateLimitStore;
|
|
46
51
|
};
|
|
52
|
+
export { MemoryStore };
|
|
53
|
+
export { SlidingWindowStore };
|
|
54
|
+
/**
|
|
55
|
+
* Sliding window rate limiter middleware
|
|
56
|
+
*
|
|
57
|
+
* More accurate than fixed window as it tracks individual request timestamps.
|
|
58
|
+
* Uses more memory but avoids the "cliff" effect where all requests at the end
|
|
59
|
+
* of one window and start of next are counted together.
|
|
60
|
+
*/
|
|
61
|
+
export declare function slidingWindowLimit(options: Options): Middleware;
|
|
47
62
|
/**
|
|
48
63
|
* Fixed window rate limiter middleware
|
|
49
64
|
*/
|
package/dist/types/router.d.ts
CHANGED
|
@@ -93,6 +93,8 @@ export declare class Router<Locals extends App.Locals = App.Locals> {
|
|
|
93
93
|
private normalizePrefix;
|
|
94
94
|
private extractPrefixParams;
|
|
95
95
|
private handleNestedRouters;
|
|
96
|
+
private hasHttpMatchAtPath;
|
|
97
|
+
private hasLocalPathMatch;
|
|
96
98
|
private handleLocalRoutes;
|
|
97
99
|
private sortRoutes;
|
|
98
100
|
private sortWsRoutes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sourceregistry/node-webserver",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "TypeScript web server for Node.js with web-standard Request and Response APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs.js",
|
|
@@ -68,16 +68,17 @@
|
|
|
68
68
|
"@semantic-release/git": "^10.0.1",
|
|
69
69
|
"@semantic-release/npm": "^13.1.3",
|
|
70
70
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
71
|
-
"@types/node": "^25.5.
|
|
72
|
-
"@
|
|
71
|
+
"@types/node": "^25.5.2",
|
|
72
|
+
"@types/ws": "^8.18.1",
|
|
73
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
73
74
|
"@vitest/ui": "^4.0.16",
|
|
75
|
+
"jsr": "^0.13.0",
|
|
74
76
|
"tsx": "^4.21.0",
|
|
75
|
-
"typedoc": "^0.28.
|
|
76
|
-
"typescript": "^
|
|
77
|
-
"vite": "^8.0.
|
|
77
|
+
"typedoc": "^0.28.18",
|
|
78
|
+
"typescript": "^6.0.2",
|
|
79
|
+
"vite": "^8.0.5",
|
|
78
80
|
"vite-plugin-dts": "^4.5.4",
|
|
79
|
-
"
|
|
80
|
-
"vitest": "^4.1.0"
|
|
81
|
+
"vitest": "^4.1.2"
|
|
81
82
|
},
|
|
82
83
|
"release": {
|
|
83
84
|
"branches": [
|
|
@@ -88,11 +89,13 @@
|
|
|
88
89
|
"@semantic-release/release-notes-generator",
|
|
89
90
|
"@semantic-release/changelog",
|
|
90
91
|
"@semantic-release/npm",
|
|
92
|
+
"./scripts/semantic-release-jsr.mjs",
|
|
91
93
|
[
|
|
92
94
|
"@semantic-release/git",
|
|
93
95
|
{
|
|
94
96
|
"assets": [
|
|
95
97
|
"package.json",
|
|
98
|
+
"jsr.json",
|
|
96
99
|
"CHANGELOG.md"
|
|
97
100
|
],
|
|
98
101
|
"message": "node-webserver(release): ${nextRelease.version}\n\n${nextRelease.notes}"
|