@lengkapp/edge 0.0.1 → 0.0.3

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.
@@ -0,0 +1,3 @@
1
+ // Type declarations for @lengkapp/edge/client.min
2
+ // The client script is a side‑effect module with no exports.
3
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -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,26 +1,42 @@
1
1
  {
2
2
  "name": "@lengkapp/edge",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Edge framework used by Lengkapp",
5
- "main": "edge-server.js",
6
- "browser": "edge-client.js",
5
+ "main": "edge-server.js",
6
+ "types": "./edge-server.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "browser": "./edge-client.js",
9
+ "types": "./edge-server.d.ts",
10
10
  "node": "./edge-server.js",
11
11
  "default": "./edge-server.js"
12
12
  },
13
- "./client": "./edge-client.js",
14
- "./server": "./edge-server.js",
15
- "./client.min": "./edge-client.min.js",
16
- "./server.min": "./edge-server.min.js",
13
+ "./client": {
14
+ "types": "./edge-client.d.ts",
15
+ "default": "./edge-client.js"
16
+ },
17
+ "./server": {
18
+ "types": "./edge-server.d.ts",
19
+ "default": "./edge-server.js"
20
+ },
21
+ "./client.min": {
22
+ "types": "./client.min.d.ts",
23
+ "default": "./edge-client.min.js"
24
+ },
25
+ "./server.min": {
26
+ "types": "./server.min.d.ts",
27
+ "default": "./edge-server.min.js"
28
+ },
17
29
  "./package.json": "./package.json"
18
30
  },
19
31
  "files": [
20
32
  "edge-client.js",
21
33
  "edge-client.min.js",
22
34
  "edge-server.js",
23
- "edge-server.min.js"
35
+ "edge-server.min.js",
36
+ "edge-server.d.ts",
37
+ "server.min.d.ts",
38
+ "edge-client.d.ts",
39
+ "client.min.d.ts"
24
40
  ],
25
41
  "scripts": {
26
42
  "test": "echo \"No tests yet\""
@@ -28,7 +44,7 @@
28
44
  "publishConfig": {
29
45
  "access": "public"
30
46
  },
31
- "keywords": ["cloudflare workers","minimal server library","minimal client library"],
47
+ "keywords": ["cloudflare workers", "minimal server library", "minimal client library"],
32
48
  "author": "Yasir Haris",
33
49
  "license": "MIT"
34
50
  }
@@ -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
+ }