cpeak 2.6.0 → 2.8.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/README.md +195 -67
- package/dist/index.d.ts +73 -42
- package/dist/index.js +503 -118
- package/dist/index.js.map +1 -1
- package/lib/index.ts +177 -123
- package/lib/internal/compression.ts +180 -0
- package/lib/internal/errors.ts +35 -0
- package/lib/internal/mimeTypes.ts +22 -0
- package/lib/internal/router.ts +259 -0
- package/lib/internal/types.ts +10 -0
- package/lib/types.ts +31 -20
- package/lib/utils/auth.ts +1 -23
- package/lib/utils/cookieParser.ts +1 -11
- package/lib/utils/cors.ts +109 -0
- package/lib/utils/index.ts +3 -4
- package/lib/utils/render.ts +18 -6
- package/lib/utils/serveStatic.ts +29 -28
- package/lib/utils/types.ts +51 -0
- package/package.json +4 -4
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface PbkdfOptions {
|
|
2
|
+
iterations?: number;
|
|
3
|
+
keylen?: number;
|
|
4
|
+
digest?: string;
|
|
5
|
+
saltSize?: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface AuthOptions extends PbkdfOptions {
|
|
9
|
+
secret: string;
|
|
10
|
+
saveToken: (
|
|
11
|
+
tokenId: string,
|
|
12
|
+
userId: string,
|
|
13
|
+
expiresAt: Date
|
|
14
|
+
) => Promise<void>;
|
|
15
|
+
findToken: (
|
|
16
|
+
tokenId: string
|
|
17
|
+
) => Promise<{ userId: string; expiresAt: Date } | null>;
|
|
18
|
+
tokenExpiry?: number;
|
|
19
|
+
hmacAlgorithm?: string;
|
|
20
|
+
tokenIdSize?: number;
|
|
21
|
+
revokeToken?: (tokenId: string) => Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface CookieOptions {
|
|
25
|
+
signed?: boolean;
|
|
26
|
+
httpOnly?: boolean;
|
|
27
|
+
secure?: boolean;
|
|
28
|
+
sameSite?: "strict" | "lax" | "none";
|
|
29
|
+
maxAge?: number; // ms
|
|
30
|
+
expires?: Date;
|
|
31
|
+
path?: string;
|
|
32
|
+
domain?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type OriginInput =
|
|
36
|
+
| string
|
|
37
|
+
| string[]
|
|
38
|
+
| RegExp
|
|
39
|
+
| boolean
|
|
40
|
+
| ((origin: string | undefined) => boolean | Promise<boolean>);
|
|
41
|
+
|
|
42
|
+
export interface CorsOptions {
|
|
43
|
+
origin?: OriginInput;
|
|
44
|
+
methods?: string | string[];
|
|
45
|
+
allowedHeaders?: string | string[];
|
|
46
|
+
exposedHeaders?: string | string[];
|
|
47
|
+
credentials?: boolean;
|
|
48
|
+
maxAge?: number;
|
|
49
|
+
preflightContinue?: boolean;
|
|
50
|
+
optionsSuccessStatus?: number;
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cpeak",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "A minimal and fast Node.js HTTP framework.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/
|
|
13
|
+
"url": "https://github.com/Cododev-Technology/cpeak.git"
|
|
14
14
|
},
|
|
15
15
|
"bugs": {
|
|
16
|
-
"url": "https://github.com/
|
|
16
|
+
"url": "https://github.com/Cododev-Technology/cpeak/issues"
|
|
17
17
|
},
|
|
18
|
-
"homepage": "https://github.com/
|
|
18
|
+
"homepage": "https://github.com/Cododev-Technology/cpeak#readme",
|
|
19
19
|
"main": "./dist/index.js",
|
|
20
20
|
"module": "./dist/index.js",
|
|
21
21
|
"types": "./dist/index.d.ts",
|