@lengkapp/edge 0.0.1 → 0.0.2
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/edge-server.d.ts +83 -0
- package/package.json +11 -5
- package/server.min.d.ts +83 -0
package/edge-server.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export const Fragment: unique symbol;
|
|
2
|
+
|
|
3
|
+
export interface JSXNode {
|
|
4
|
+
type: any;
|
|
5
|
+
props: Record<string, any>;
|
|
6
|
+
children: any[];
|
|
7
|
+
__isJSX: true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function jsx(
|
|
11
|
+
type: any,
|
|
12
|
+
props?: Record<string, any> | null,
|
|
13
|
+
...children: any[]
|
|
14
|
+
): JSXNode;
|
|
15
|
+
|
|
16
|
+
export function renderToString(node: any): string;
|
|
17
|
+
|
|
18
|
+
export interface RouteOptions {
|
|
19
|
+
auth?: boolean | { role?: string; scopes?: string[] };
|
|
20
|
+
rateLimit?: boolean | { max?: number; window?: number };
|
|
21
|
+
cors?: boolean | { origin?: string; methods?: string; headers?: string };
|
|
22
|
+
validate?: (ctx: Context) => boolean | Promise<boolean>;
|
|
23
|
+
log?: boolean;
|
|
24
|
+
cache?: boolean | { ttl?: number; staleWhileRevalidate?: number };
|
|
25
|
+
compress?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class Context {
|
|
29
|
+
req: Request;
|
|
30
|
+
env: any;
|
|
31
|
+
executionCtx: ExecutionContext;
|
|
32
|
+
params: Record<string, string>;
|
|
33
|
+
status: number;
|
|
34
|
+
headers: Headers;
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
request: Request,
|
|
38
|
+
env: any,
|
|
39
|
+
executionCtx: ExecutionContext,
|
|
40
|
+
params?: Record<string, string>,
|
|
41
|
+
parsedUrl?: URL
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
getCookie(name: string): string | null;
|
|
45
|
+
get query(): URLSearchParams;
|
|
46
|
+
setCookie(name: string, value: string, options?: Record<string, any>): void;
|
|
47
|
+
deleteCookie(name: string, options?: Record<string, any>): void;
|
|
48
|
+
text(data: string, status?: number, headers?: Record<string, string>): Response;
|
|
49
|
+
json(data: any, status?: number, headers?: Record<string, string>): Response;
|
|
50
|
+
html(data: string, status?: number, headers?: Record<string, string>): Response;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class Edge {
|
|
54
|
+
constructor();
|
|
55
|
+
authKvBinding: string;
|
|
56
|
+
rateLimitKvBinding: string;
|
|
57
|
+
defaults: {
|
|
58
|
+
cors: { origin: string; methods: string };
|
|
59
|
+
};
|
|
60
|
+
scheduledHandler: ((...args: any[]) => void) | null;
|
|
61
|
+
|
|
62
|
+
get(path: string, handler: (ctx: Context) => any): void;
|
|
63
|
+
get(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
64
|
+
post(path: string, handler: (ctx: Context) => any): void;
|
|
65
|
+
post(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
66
|
+
put(path: string, handler: (ctx: Context) => any): void;
|
|
67
|
+
put(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
68
|
+
delete(path: string, handler: (ctx: Context) => any): void;
|
|
69
|
+
delete(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
70
|
+
patch(path: string, handler: (ctx: Context) => any): void;
|
|
71
|
+
patch(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
72
|
+
options(path: string, handler: (ctx: Context) => any): void;
|
|
73
|
+
options(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
74
|
+
head(path: string, handler: (ctx: Context) => any): void;
|
|
75
|
+
head(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
76
|
+
scheduled(handler: (...args: any[]) => void): void;
|
|
77
|
+
|
|
78
|
+
fetch(
|
|
79
|
+
request: Request,
|
|
80
|
+
env: any,
|
|
81
|
+
executionCtx: ExecutionContext
|
|
82
|
+
): Promise<Response>;
|
|
83
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lengkapp/edge",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Edge framework used by Lengkapp",
|
|
5
|
-
"main": "edge-server.js",
|
|
5
|
+
"main": "edge-server.js",
|
|
6
6
|
"browser": "edge-client.js",
|
|
7
|
+
"types": "./edge-server.d.ts",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
9
10
|
"browser": "./edge-client.js",
|
|
@@ -13,14 +14,19 @@
|
|
|
13
14
|
"./client": "./edge-client.js",
|
|
14
15
|
"./server": "./edge-server.js",
|
|
15
16
|
"./client.min": "./edge-client.min.js",
|
|
16
|
-
"./server.min":
|
|
17
|
+
"./server.min": {
|
|
18
|
+
"types": "./server.min.d.ts",
|
|
19
|
+
"default": "./edge-server.min.js"
|
|
20
|
+
},
|
|
17
21
|
"./package.json": "./package.json"
|
|
18
22
|
},
|
|
19
23
|
"files": [
|
|
20
24
|
"edge-client.js",
|
|
21
25
|
"edge-client.min.js",
|
|
22
26
|
"edge-server.js",
|
|
23
|
-
"edge-server.min.js"
|
|
27
|
+
"edge-server.min.js",
|
|
28
|
+
"edge-server.d.ts",
|
|
29
|
+
"server.min.d.ts"
|
|
24
30
|
],
|
|
25
31
|
"scripts": {
|
|
26
32
|
"test": "echo \"No tests yet\""
|
|
@@ -28,7 +34,7 @@
|
|
|
28
34
|
"publishConfig": {
|
|
29
35
|
"access": "public"
|
|
30
36
|
},
|
|
31
|
-
"keywords": ["cloudflare workers","minimal server library","minimal client library"],
|
|
37
|
+
"keywords": ["cloudflare workers", "minimal server library", "minimal client library"],
|
|
32
38
|
"author": "Yasir Haris",
|
|
33
39
|
"license": "MIT"
|
|
34
40
|
}
|
package/server.min.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export const Fragment: unique symbol;
|
|
2
|
+
|
|
3
|
+
export interface JSXNode {
|
|
4
|
+
type: any;
|
|
5
|
+
props: Record<string, any>;
|
|
6
|
+
children: any[];
|
|
7
|
+
__isJSX: true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function jsx(
|
|
11
|
+
type: any,
|
|
12
|
+
props?: Record<string, any> | null,
|
|
13
|
+
...children: any[]
|
|
14
|
+
): JSXNode;
|
|
15
|
+
|
|
16
|
+
export function renderToString(node: any): string;
|
|
17
|
+
|
|
18
|
+
export interface RouteOptions {
|
|
19
|
+
auth?: boolean | { role?: string; scopes?: string[] };
|
|
20
|
+
rateLimit?: boolean | { max?: number; window?: number };
|
|
21
|
+
cors?: boolean | { origin?: string; methods?: string; headers?: string };
|
|
22
|
+
validate?: (ctx: Context) => boolean | Promise<boolean>;
|
|
23
|
+
log?: boolean;
|
|
24
|
+
cache?: boolean | { ttl?: number; staleWhileRevalidate?: number };
|
|
25
|
+
compress?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class Context {
|
|
29
|
+
req: Request;
|
|
30
|
+
env: any;
|
|
31
|
+
executionCtx: ExecutionContext;
|
|
32
|
+
params: Record<string, string>;
|
|
33
|
+
status: number;
|
|
34
|
+
headers: Headers;
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
request: Request,
|
|
38
|
+
env: any,
|
|
39
|
+
executionCtx: ExecutionContext,
|
|
40
|
+
params?: Record<string, string>,
|
|
41
|
+
parsedUrl?: URL
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
getCookie(name: string): string | null;
|
|
45
|
+
get query(): URLSearchParams;
|
|
46
|
+
setCookie(name: string, value: string, options?: Record<string, any>): void;
|
|
47
|
+
deleteCookie(name: string, options?: Record<string, any>): void;
|
|
48
|
+
text(data: string, status?: number, headers?: Record<string, string>): Response;
|
|
49
|
+
json(data: any, status?: number, headers?: Record<string, string>): Response;
|
|
50
|
+
html(data: string, status?: number, headers?: Record<string, string>): Response;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class Edge {
|
|
54
|
+
constructor();
|
|
55
|
+
authKvBinding: string;
|
|
56
|
+
rateLimitKvBinding: string;
|
|
57
|
+
defaults: {
|
|
58
|
+
cors: { origin: string; methods: string };
|
|
59
|
+
};
|
|
60
|
+
scheduledHandler: ((...args: any[]) => void) | null;
|
|
61
|
+
|
|
62
|
+
get(path: string, handler: (ctx: Context) => any): void;
|
|
63
|
+
get(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
64
|
+
post(path: string, handler: (ctx: Context) => any): void;
|
|
65
|
+
post(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
66
|
+
put(path: string, handler: (ctx: Context) => any): void;
|
|
67
|
+
put(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
68
|
+
delete(path: string, handler: (ctx: Context) => any): void;
|
|
69
|
+
delete(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
70
|
+
patch(path: string, handler: (ctx: Context) => any): void;
|
|
71
|
+
patch(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
72
|
+
options(path: string, handler: (ctx: Context) => any): void;
|
|
73
|
+
options(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
74
|
+
head(path: string, handler: (ctx: Context) => any): void;
|
|
75
|
+
head(path: string, options: RouteOptions, handler: (ctx: Context) => any): void;
|
|
76
|
+
scheduled(handler: (...args: any[]) => void): void;
|
|
77
|
+
|
|
78
|
+
fetch(
|
|
79
|
+
request: Request,
|
|
80
|
+
env: any,
|
|
81
|
+
executionCtx: ExecutionContext
|
|
82
|
+
): Promise<Response>;
|
|
83
|
+
}
|