fetchwork 1.0.10 → 1.0.12
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 +154 -123
- package/dist/adapters/bun.cjs.map +1 -1
- package/dist/adapters/bun.mjs.map +1 -1
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/index.cjs.map +5 -5
- package/dist/adapters/index.mjs.map +5 -5
- package/dist/adapters/node.cjs.map +2 -2
- package/dist/adapters/node.d.ts.map +1 -1
- package/dist/adapters/node.mjs.map +2 -2
- package/dist/adapters/vercel.cjs.map +2 -2
- package/dist/adapters/vercel.d.ts.map +1 -1
- package/dist/adapters/vercel.mjs.map +2 -2
- package/dist/context.d.ts +19 -8
- package/dist/context.d.ts.map +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +14 -9
- package/dist/index.d.ts +10 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +14 -9
- package/dist/middlewares/bodyLimit.d.ts +11 -0
- package/dist/middlewares/bodyLimit.d.ts.map +1 -0
- package/dist/middlewares/bodyParser.d.ts.map +1 -1
- package/dist/middlewares/cors.d.ts.map +1 -1
- package/dist/middlewares/docs.d.ts +1 -1
- package/dist/middlewares/docs.d.ts.map +1 -1
- package/dist/middlewares/index.d.ts +2 -0
- package/dist/middlewares/index.d.ts.map +1 -1
- package/dist/middlewares/rateLimiter.d.ts +40 -0
- package/dist/middlewares/rateLimiter.d.ts.map +1 -0
- package/dist/middlewares/validator.d.ts +2 -2
- package/dist/middlewares/validator.d.ts.map +1 -1
- package/dist/pipeline.d.ts +4 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pool.d.ts +4 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/router.d.ts +12 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/runtime.d.ts +24 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/type.d.ts +49 -0
- package/dist/type.d.ts.map +1 -0
- package/package.json +4 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Context } from "./context";
|
|
2
|
+
import type { Handler, Middleware, RouteEntry } from "./type";
|
|
3
|
+
export declare function executePipeline(ctx: Context, matchedRoute: RouteEntry | null, globalMiddlewares: Middleware[], customNotFoundHandler?: Handler, customErrorHandler?: (err: Error, ctx: Context) => Response | Promise<Response>): Promise<Response>;
|
|
4
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE9D,wBAAsB,eAAe,CACnC,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,UAAU,GAAG,IAAI,EAC/B,iBAAiB,EAAE,UAAU,EAAE,EAC/B,qBAAqB,CAAC,EAAE,OAAO,EAC/B,kBAAkB,CAAC,EAAE,CACnB,GAAG,EAAE,KAAK,EACV,GAAG,EAAE,OAAO,KACT,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAChC,OAAO,CAAC,QAAQ,CAAC,CAoDnB"}
|
package/dist/pool.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,cAAc,CAC5B,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAOT;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAKjD"}
|
package/dist/router.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Handler, Middleware, RouteDocDetail, RouteEntry } from "./type";
|
|
2
|
+
export declare class Router {
|
|
3
|
+
private roots;
|
|
4
|
+
private staticRoutes;
|
|
5
|
+
routes: RouteEntry[];
|
|
6
|
+
staticRoutesMap: Map<string, RouteEntry>;
|
|
7
|
+
addRoute(method: string, path: string, routeMiddlewares: Middleware[], handler: Handler, detail?: RouteDocDetail): void;
|
|
8
|
+
private _insertToRadix;
|
|
9
|
+
findRoute(method: string, pathname: string, outParams: Record<string, string>): RouteEntry | null;
|
|
10
|
+
private _searchRadix;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAW9E,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,YAAY,CAAiC;IAG9C,MAAM,EAAE,UAAU,EAAE,CAAM;IAC1B,eAAe,0BAAqB;IAE3C,QAAQ,CACN,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,UAAU,EAAE,EAC9B,OAAO,EAAE,OAAO,EAChB,MAAM,CAAC,EAAE,cAAc,GACtB,IAAI,CAqCN;IAED,OAAO,CAAC,cAAc;IA4CtB,SAAS,CACP,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,UAAU,GAAG,IAAI,CAmBnB;IAED,OAAO,CAAC,YAAY;CAmDrB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modul Abstraksi Runtime Helper untuk FetchWork
|
|
3
|
+
* Menangani perbedaan spesifik antar runtime (Bun, Node.js, Deno, dll.) secara aman.
|
|
4
|
+
*/
|
|
5
|
+
export declare const isBun: boolean;
|
|
6
|
+
export declare const isDeno: boolean;
|
|
7
|
+
export declare const isNode: boolean;
|
|
8
|
+
export declare const runtime: {
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Menjalankan Garbage Collection secara aman jika didukung oleh runtime
|
|
12
|
+
*/
|
|
13
|
+
gc(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Mengambil environment variable secara universal
|
|
16
|
+
*/
|
|
17
|
+
getEnv(key: string): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* High-resolution timestamp untuk pengukuran performa / metrics
|
|
20
|
+
*/
|
|
21
|
+
now(): number;
|
|
22
|
+
nextTick(callback: () => void): void;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,KAAK,SAA6B,CAAC;AAChD,eAAO,MAAM,MAAM,SAA4D,CAAC;AAChF,eAAO,MAAM,MAAM,SAAsD,CAAC;AAE1E,eAAO,MAAM,OAAO;;IAUlB;;OAEG;UACG,IAAI;IAWV;;OAEG;gBACS,MAAM,GAAG,MAAM,GAAG,SAAS;IAavC;;OAEG;WACI,MAAM;uBAIM,MAAM,IAAI,GAAG,IAAI;CAGrC,CAAC"}
|
package/dist/type.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Context } from "./context";
|
|
2
|
+
export type Handler = (c: Context) => Response | Promise<Response>;
|
|
3
|
+
export type NotFoundHandler = (c: Context) => Response | Promise<Response>;
|
|
4
|
+
export type ErrorHandler = (err: Error, c: Context) => Response | Promise<Response>;
|
|
5
|
+
export type Middleware = (c: Context, next: () => Promise<Response>) => Promise<Response>;
|
|
6
|
+
export type DocParameter = {
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
type?: "string" | "number" | "integer" | "boolean" | "array";
|
|
11
|
+
};
|
|
12
|
+
export type DocBodyProperty = {
|
|
13
|
+
type: "string" | "number" | "integer" | "boolean" | "array" | "object";
|
|
14
|
+
description?: string;
|
|
15
|
+
example?: any;
|
|
16
|
+
};
|
|
17
|
+
export type DocHeaderParameter = {
|
|
18
|
+
name?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
type?: "string" | "number" | "integer" | "boolean";
|
|
22
|
+
};
|
|
23
|
+
export type RouteDocDetail = {
|
|
24
|
+
tags?: string[];
|
|
25
|
+
summary?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
deprecated?: boolean;
|
|
28
|
+
query?: Record<string, DocParameter>;
|
|
29
|
+
body?: Record<string, DocBodyProperty>;
|
|
30
|
+
headers?: Record<string, DocHeaderParameter>;
|
|
31
|
+
};
|
|
32
|
+
export type RouteEntry = {
|
|
33
|
+
method: string;
|
|
34
|
+
path: string;
|
|
35
|
+
regex: RegExp;
|
|
36
|
+
paramNames: string[];
|
|
37
|
+
middlewares: Middleware[];
|
|
38
|
+
handler: Handler;
|
|
39
|
+
isDynamic: boolean;
|
|
40
|
+
detail?: RouteDocDetail;
|
|
41
|
+
};
|
|
42
|
+
export type RouteOptions = {
|
|
43
|
+
path: string;
|
|
44
|
+
validator?: Middleware | Middleware[];
|
|
45
|
+
middleware?: Middleware | Middleware[];
|
|
46
|
+
controller: Handler;
|
|
47
|
+
detail?: RouteDocDetail;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WA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IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,CAAC;IACtC,UAAU,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,CAAC;IACvC,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fetchwork",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "An ultra-fast, lightweight, and type-safe web framework built on W3C Web Standards with multi-runtime adapter support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -116,5 +116,8 @@
|
|
|
116
116
|
"autocannon": "^8.0.0",
|
|
117
117
|
"typescript": "^7",
|
|
118
118
|
"zod": "^4.6.7"
|
|
119
|
+
},
|
|
120
|
+
"dependencies": {
|
|
121
|
+
"koffi": "^3.3.3"
|
|
119
122
|
}
|
|
120
123
|
}
|