@adonix.org/cloud-spark 0.0.47 → 0.0.50
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/dist/index.d.ts +2 -3
- package/dist/index.js +18 -21
- package/dist/index.js.map +1 -1
- package/package.json +21 -2
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ declare enum Method {
|
|
|
18
18
|
OPTIONS = "OPTIONS"
|
|
19
19
|
}
|
|
20
20
|
declare function isMethod(value: string): value is Method;
|
|
21
|
-
declare function ensure<K, V>(map: Map<K, V>, key: K, factory: () => V): V;
|
|
22
21
|
declare function getContentType(type: MimeType): string;
|
|
23
22
|
declare enum MimeType {
|
|
24
23
|
PLAIN_TEXT = "text/plain",
|
|
@@ -84,7 +83,7 @@ declare class WorkerResponse {
|
|
|
84
83
|
protected readonly mimeType: MimeType;
|
|
85
84
|
private _headers;
|
|
86
85
|
private _body;
|
|
87
|
-
constructor(cors: CorsProvider, content?:
|
|
86
|
+
constructor(cors: CorsProvider, content?: BodyInit | null, code?: StatusCodes, mimeType?: MimeType);
|
|
88
87
|
createResponse(): Response;
|
|
89
88
|
protected get responseInit(): ResponseInit;
|
|
90
89
|
protected get body(): BodyInit | null;
|
|
@@ -202,4 +201,4 @@ declare abstract class RoutedWorker extends BasicWorker {
|
|
|
202
201
|
protected delete(): Promise<Response>;
|
|
203
202
|
}
|
|
204
203
|
|
|
205
|
-
export { BadRequest, BasicWorker, type CorsProvider, type ErrorJson, Forbidden, Head, HtmlResponse, HttpError, InternalServerError, JsonResponse, Method, MethodNotAllowed, MimeType, NotFound, NotImplemented, Options, Route, type RouteCallback, type RouteInit, RoutedWorker, Routes, ServiceUnavailable, TextResponse, Time, Unauthorized, WorkerResponse,
|
|
204
|
+
export { BadRequest, BasicWorker, type CorsProvider, type ErrorJson, Forbidden, Head, HtmlResponse, HttpError, InternalServerError, JsonResponse, Method, MethodNotAllowed, MimeType, NotFound, NotImplemented, Options, Route, type RouteCallback, type RouteInit, RoutedWorker, Routes, ServiceUnavailable, TextResponse, Time, Unauthorized, WorkerResponse, getContentType, isMethod };
|
package/dist/index.js
CHANGED
|
@@ -9,28 +9,20 @@ var Time = {
|
|
|
9
9
|
Day: 60 * 60 * 24,
|
|
10
10
|
Week: 60 * 60 * 24 * 7
|
|
11
11
|
};
|
|
12
|
-
var Method = /* @__PURE__ */ ((
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return
|
|
12
|
+
var Method = /* @__PURE__ */ ((Method3) => {
|
|
13
|
+
Method3["GET"] = "GET";
|
|
14
|
+
Method3["PUT"] = "PUT";
|
|
15
|
+
Method3["POST"] = "POST";
|
|
16
|
+
Method3["PATCH"] = "PATCH";
|
|
17
|
+
Method3["DELETE"] = "DELETE";
|
|
18
|
+
Method3["HEAD"] = "HEAD";
|
|
19
|
+
Method3["OPTIONS"] = "OPTIONS";
|
|
20
|
+
return Method3;
|
|
21
21
|
})(Method || {});
|
|
22
22
|
var METHOD_SET = new Set(Object.values(Method));
|
|
23
23
|
function isMethod(value) {
|
|
24
24
|
return METHOD_SET.has(value);
|
|
25
25
|
}
|
|
26
|
-
function ensure(map, key, factory) {
|
|
27
|
-
let value = map.get(key);
|
|
28
|
-
if (value === void 0) {
|
|
29
|
-
value = factory();
|
|
30
|
-
map.set(key, value);
|
|
31
|
-
}
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
26
|
function getContentType(type) {
|
|
35
27
|
if (ADD_CHARSET.has(type)) {
|
|
36
28
|
return `${type}; charset=utf-8`;
|
|
@@ -345,7 +337,7 @@ var BasicWorker = class {
|
|
|
345
337
|
}
|
|
346
338
|
};
|
|
347
339
|
|
|
348
|
-
// src/
|
|
340
|
+
// src/routes.ts
|
|
349
341
|
var Route = class {
|
|
350
342
|
constructor(pattern, callback) {
|
|
351
343
|
this.callback = callback;
|
|
@@ -356,13 +348,19 @@ var Route = class {
|
|
|
356
348
|
var Routes = class {
|
|
357
349
|
map = /* @__PURE__ */ new Map();
|
|
358
350
|
add(method, route) {
|
|
359
|
-
|
|
351
|
+
const existing = this.map.get(method);
|
|
352
|
+
if (existing) {
|
|
353
|
+
existing.push(route);
|
|
354
|
+
} else {
|
|
355
|
+
this.map.set(method, [route]);
|
|
356
|
+
}
|
|
360
357
|
return this;
|
|
361
358
|
}
|
|
362
359
|
get(method, url) {
|
|
363
360
|
const routes = this.map.get(method);
|
|
364
361
|
if (!routes) return void 0;
|
|
365
|
-
|
|
362
|
+
const pathname = new URL(url).pathname;
|
|
363
|
+
return routes.find(({ pattern }) => pattern.test(pathname));
|
|
366
364
|
}
|
|
367
365
|
};
|
|
368
366
|
|
|
@@ -424,7 +422,6 @@ export {
|
|
|
424
422
|
Time,
|
|
425
423
|
Unauthorized,
|
|
426
424
|
WorkerResponse,
|
|
427
|
-
ensure,
|
|
428
425
|
getContentType,
|
|
429
426
|
isMethod
|
|
430
427
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/common.ts","../src/response.ts","../src/basic-worker.ts","../src/route.ts","../src/routed-worker.ts"],"sourcesContent":["/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { StatusCodes } from \"http-status-codes\";\n\nexport * from \"./basic-worker\";\nexport * from \"./common\";\nexport * from \"./response\";\nexport * from \"./route\";\nexport * from \"./routed-worker\";\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Time = {\n Second: 1,\n Minute: 60,\n Hour: 60 * 60,\n Day: 60 * 60 * 24,\n Week: 60 * 60 * 24 * 7,\n} as const;\n\nexport enum Method {\n GET = \"GET\",\n PUT = \"PUT\",\n POST = \"POST\",\n PATCH = \"PATCH\",\n DELETE = \"DELETE\",\n HEAD = \"HEAD\",\n OPTIONS = \"OPTIONS\",\n}\n\nconst METHOD_SET: Set<string> = new Set(Object.values(Method));\n\nexport function isMethod(value: string): value is Method {\n return METHOD_SET.has(value);\n}\n\nexport function ensure<K, V>(map: Map<K, V>, key: K, factory: () => V): V {\n let value = map.get(key);\n if (value === undefined) {\n value = factory();\n map.set(key, value);\n }\n return value;\n}\n\nexport function getContentType(type: MimeType): string {\n if (ADD_CHARSET.has(type)) {\n return `${type}; charset=utf-8`;\n }\n return type;\n}\n\nexport enum MimeType {\n PLAIN_TEXT = \"text/plain\",\n HTML = \"text/html\",\n CSS = \"text/css\",\n CSV = \"text/csv\",\n XML = \"text/xml\",\n MARKDOWN = \"text/markdown\",\n RICH_TEXT = \"text/richtext\",\n JSON = \"application/json\",\n XML_APP = \"application/xml\",\n YAML = \"application/x-yaml\",\n FORM_URLENCODED = \"application/x-www-form-urlencoded\",\n NDJSON = \"application/x-ndjson\",\n MSGPACK = \"application/x-msgpack\",\n PROTOBUF = \"application/x-protobuf\",\n MULTIPART_FORM_DATA = \"multipart/form-data\",\n MULTIPART_MIXED = \"multipart/mixed\",\n MULTIPART_ALTERNATIVE = \"multipart/alternative\",\n MULTIPART_DIGEST = \"multipart/digest\",\n MULTIPART_RELATED = \"multipart/related\",\n MULTIPART_SIGNED = \"multipart/signed\",\n MULTIPART_ENCRYPTED = \"multipart/encrypted\",\n OCTET_STREAM = \"application/octet-stream\",\n PDF = \"application/pdf\",\n ZIP = \"application/zip\",\n GZIP = \"application/gzip\",\n MSWORD = \"application/msword\",\n DOCX = \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n EXCEL = \"application/vnd.ms-excel\",\n XLSX = \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n POWERPOINT = \"application/vnd.ms-powerpoint\",\n PPTX = \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n ICO = \"image/x-icon\",\n ICO_MS = \"image/vnd.microsoft.icon\",\n GIF = \"image/gif\",\n PNG = \"image/png\",\n JPEG = \"image/jpeg\",\n WEBP = \"image/webp\",\n SVG = \"image/svg+xml\",\n HEIF = \"image/heif\",\n AVIF = \"image/avif\",\n EVENT_STREAM = \"text/event-stream\",\n TAR = \"application/x-tar\",\n BZIP2 = \"application/x-bzip2\",\n}\n\nconst ADD_CHARSET: Set<MimeType> = new Set([\n MimeType.PLAIN_TEXT,\n MimeType.HTML,\n MimeType.CSS,\n MimeType.CSV,\n MimeType.MARKDOWN,\n MimeType.XML,\n MimeType.JSON,\n MimeType.XML_APP,\n MimeType.FORM_URLENCODED,\n MimeType.NDJSON,\n MimeType.RICH_TEXT,\n MimeType.SVG,\n]);\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getReasonPhrase, StatusCodes } from \"http-status-codes\";\nimport { getContentType, Method, MimeType } from \"./common\";\n\nexport interface CorsProvider {\n getOrigin(): string | null;\n getAllowOrigins(): string[];\n getAllowMethods(): Method[];\n getAllowHeaders(): string[];\n getMaxAge(): number;\n}\n\nexport interface ErrorJson {\n code: number;\n error: string;\n details: string;\n}\n\nexport class WorkerResponse {\n private _headers: Headers = new Headers();\n private _body: BodyInit | null;\n\n constructor(\n protected readonly cors: CorsProvider,\n content: string | null = null,\n protected readonly code: StatusCodes = StatusCodes.OK,\n protected readonly mimeType: MimeType = MimeType.JSON\n ) {\n this._body = this.code === StatusCodes.NO_CONTENT ? null : content;\n }\n\n public createResponse(): Response {\n this.addCorsHeaders();\n if (this.body) {\n this.headers.set(\"Content-Type\", getContentType(this.mimeType));\n }\n return new Response(this.body, this.responseInit);\n }\n\n protected get responseInit(): ResponseInit {\n return {\n headers: this.headers,\n status: this.code,\n statusText: getReasonPhrase(this.code),\n };\n }\n\n protected get body(): BodyInit | null {\n return this._body;\n }\n\n protected get headers(): Headers {\n return this._headers;\n }\n\n protected set headers(headers: Headers) {\n this._headers = headers;\n }\n\n protected addCorsHeaders(): void {\n const origin = this.cors.getOrigin();\n if (!origin) return; // no Origin, skip CORS\n\n if (this.getAllowOrigins().includes(\"*\")) {\n this.headers.set(\"Access-Control-Allow-Origin\", \"*\");\n } else if (this.getAllowOrigins().includes(origin)) {\n this.headers.set(\"Access-Control-Allow-Origin\", origin);\n this.headers.set(\"Access-Control-Allow-Credentials\", \"true\");\n this.headers.set(\"Vary\", \"Origin\");\n }\n this.headers.set(\"Access-Control-Allow-Headers\", this.getAllowHeaders());\n this.headers.set(\"Access-Control-Allow-Methods\", this.getAllowMethods());\n this.headers.set(\"Access-Control-Max-Age\", this.getMaxAge());\n this.headers.set(\"X-Content-Type-Options\", \"nosniff\");\n }\n\n protected getAllowMethods(): string {\n return this.cors.getAllowMethods().join(\", \");\n }\n\n protected getAllowHeaders(): string {\n return this.cors.getAllowHeaders().join(\", \");\n }\n\n protected getAllowOrigins(): string[] {\n return this.cors.getAllowOrigins();\n }\n\n protected getMaxAge(): string {\n return String(this.cors.getMaxAge());\n }\n}\n\nexport class JsonResponse extends WorkerResponse {\n private _json: object;\n constructor(cors: CorsProvider, content: object = {}, code: StatusCodes = StatusCodes.OK) {\n super(cors, null, code, MimeType.JSON);\n this._json = content;\n }\n\n public get json(): object {\n return this._json;\n }\n\n public set json(json: object) {\n this._json = json;\n }\n\n protected override get body(): string {\n return JSON.stringify(this.json);\n }\n}\n\nexport class HtmlResponse extends WorkerResponse {\n constructor(\n cors: CorsProvider,\n content: string,\n code: StatusCodes = StatusCodes.OK,\n type: MimeType = MimeType.HTML\n ) {\n super(cors, content, code, type);\n }\n}\n\nexport class TextResponse extends WorkerResponse {\n constructor(\n cors: CorsProvider,\n content: string,\n code: StatusCodes = StatusCodes.OK,\n type: MimeType = MimeType.PLAIN_TEXT\n ) {\n super(cors, content, code, type);\n }\n}\n\n/**\n * Remove the body from a GET response.\n */\nexport class Head extends WorkerResponse {\n constructor(cors: CorsProvider, response: Response) {\n super(cors, null, response.status);\n this.headers = new Headers(response.headers);\n }\n}\n\nexport class Options extends WorkerResponse {\n constructor(cors: CorsProvider) {\n super(cors, null, StatusCodes.NO_CONTENT);\n this.headers.set(\"Allow\", this.getAllowMethods());\n }\n}\n\nexport class HttpError extends JsonResponse {\n constructor(cors: CorsProvider, code: StatusCodes, protected details?: string) {\n super(cors, {}, code);\n }\n\n public override get json(): ErrorJson {\n return {\n code: this.code,\n error: getReasonPhrase(this.code),\n details: this.details ?? getReasonPhrase(this.code),\n };\n }\n}\n\nexport class BadRequest extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.BAD_REQUEST, detail);\n }\n}\n\nexport class Unauthorized extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.UNAUTHORIZED, detail);\n }\n}\n\nexport class Forbidden extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.FORBIDDEN, detail);\n }\n}\n\nexport class NotFound extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.NOT_FOUND, detail);\n }\n}\n\nexport class MethodNotAllowed extends HttpError {\n constructor(cors: CorsProvider, method: string) {\n super(cors, StatusCodes.METHOD_NOT_ALLOWED, `${method} method not allowed.`);\n this.headers.set(\"Allow\", this.getAllowMethods());\n }\n\n public override get json(): ErrorJson & { allowed: Method[] } {\n return {\n ...super.json,\n allowed: this.cors.getAllowMethods(),\n };\n }\n}\n\nexport class InternalServerError extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.INTERNAL_SERVER_ERROR, detail);\n }\n}\n\nexport class NotImplemented extends HttpError {\n constructor(cors: CorsProvider) {\n super(cors, StatusCodes.NOT_IMPLEMENTED);\n }\n}\n\nexport class ServiceUnavailable extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.SERVICE_UNAVAILABLE, detail);\n }\n}\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isMethod, Method, Time } from \"./common\";\nimport {\n CorsProvider,\n Head,\n InternalServerError,\n MethodNotAllowed,\n NotImplemented,\n Options,\n WorkerResponse,\n} from \"./response\";\n\nexport abstract class BasicWorker implements CorsProvider {\n constructor(\n private readonly _request: Request,\n private readonly _env: Env = {},\n private readonly _ctx?: ExecutionContext\n ) {}\n\n protected get request(): Request {\n return this._request;\n }\n\n protected get env(): Env {\n return this._env;\n }\n\n protected get ctx(): ExecutionContext | undefined {\n return this._ctx;\n }\n\n public async fetch(): Promise<Response> {\n if (!this.isAllowed(this.request.method)) {\n return this.getResponse(MethodNotAllowed, this.request.method);\n }\n\n try {\n return await this.dispatch(this.request);\n } catch (error) {\n return this.getResponse(InternalServerError, String(error));\n }\n }\n\n protected async dispatch(request: Request): Promise<Response> {\n const method = request.method as Method;\n const handler: Record<Method, () => Promise<Response>> = {\n GET: () => this.get(),\n PUT: () => this.put(),\n POST: () => this.post(),\n PATCH: () => this.patch(),\n DELETE: () => this.delete(),\n HEAD: () => this.head(),\n OPTIONS: () => this.options(),\n };\n return (handler[method] ?? (() => this.getResponse(MethodNotAllowed, method)))();\n }\n\n protected async get(): Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected async put(): Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected async post(): Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected async patch(): Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected async delete(): Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected async options(): Promise<Response> {\n return this.getResponse(Options);\n }\n\n protected async head(): Promise<Response> {\n // Dispatch a new GET request created from the HEAD request \n // and return the GET response with the body removed.\n return this.getResponse(\n Head,\n await this.dispatch(new Request(this.request, { method: Method.GET }))\n );\n }\n\n protected getResponse<\n T extends WorkerResponse,\n Ctor extends new (cors: CorsProvider, ...args: any[]) => T\n >(\n ResponseClass: Ctor,\n ...args: ConstructorParameters<Ctor> extends [any, ...infer R] ? R : never\n ): Response {\n return new ResponseClass(this, ...args).createResponse();\n }\n\n public isAllowed(method: string): boolean {\n return isMethod(method) && this.getAllowMethods().includes(method);\n }\n\n public getAllowOrigins(): string[] {\n return [\"*\"];\n }\n\n public getAllowMethods(): Method[] {\n return [Method.GET, Method.OPTIONS, Method.HEAD];\n }\n\n public getAllowHeaders(): string[] {\n return [\"Content-Type\"];\n }\n\n public getMaxAge(): number {\n return Time.Week;\n }\n\n public getOrigin(): string | null {\n return this.request.headers.get(\"Origin\");\n }\n}\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ensure, Method } from \"./common\";\n\nexport type RouteCallback = (...matches: string[]) => Response | Promise<Response>;\n\nexport type RouteInit = [Method, string, RouteCallback];\n\nexport class Route {\n public readonly pattern: RegExp;\n\n constructor(pattern: RegExp | string, public readonly callback: RouteCallback) {\n this.pattern = new RegExp(pattern);\n }\n}\n\nexport class Routes {\n private readonly map = new Map<Method, Route[]>();\n\n public add(method: Method, route: Route) {\n ensure(this.map, method, () => []).push(route);\n return this;\n }\n\n public get(method: Method, url: string): Route | undefined {\n const routes = this.map.get(method);\n if (!routes) return undefined;\n\n return routes.find(({ pattern }) => pattern.test(new URL(url).pathname));\n }\n}\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BasicWorker } from \"./basic-worker\";\nimport { Method } from \"./common\";\nimport { NotFound } from \"./response\";\nimport { Route, Routes, RouteInit, RouteCallback } from \"./route\";\n\nexport abstract class RoutedWorker extends BasicWorker {\n private readonly routes: Routes = new Routes();\n\n protected initialize(routes: RouteInit[]) {\n routes.forEach(([method, pattern, callback]) => {\n this.add(method, pattern, callback);\n });\n }\n\n protected add(method: Method, pattern: string, callback: RouteCallback) {\n this.routes.add(method, new Route(pattern, callback));\n return this;\n }\n\n protected async dispatch(request: Request): Promise<Response> {\n const route = this.routes.get(request.method as Method, request.url);\n if (!route) return super.dispatch(request);\n\n const match = new URL(request.url).pathname.match(route.pattern) ?? [];\n return route.callback.call(this, ...match);\n }\n\n protected override async get(): Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override async put(): Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override async post(): Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override async patch(): Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override async delete(): Promise<Response> {\n return this.getResponse(NotFound);\n }\n}\n"],"mappings":";AAgBA,SAAS,eAAAA,oBAAmB;;;ACArB,IAAM,OAAO;AAAA,EAChB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM,KAAK;AAAA,EACX,KAAK,KAAK,KAAK;AAAA,EACf,MAAM,KAAK,KAAK,KAAK;AACzB;AAEO,IAAK,SAAL,kBAAKC,YAAL;AACH,EAAAA,QAAA,SAAM;AACN,EAAAA,QAAA,SAAM;AACN,EAAAA,QAAA,UAAO;AACP,EAAAA,QAAA,WAAQ;AACR,EAAAA,QAAA,YAAS;AACT,EAAAA,QAAA,UAAO;AACP,EAAAA,QAAA,aAAU;AAPF,SAAAA;AAAA,GAAA;AAUZ,IAAM,aAA0B,IAAI,IAAI,OAAO,OAAO,MAAM,CAAC;AAEtD,SAAS,SAAS,OAAgC;AACrD,SAAO,WAAW,IAAI,KAAK;AAC/B;AAEO,SAAS,OAAa,KAAgB,KAAQ,SAAqB;AACtE,MAAI,QAAQ,IAAI,IAAI,GAAG;AACvB,MAAI,UAAU,QAAW;AACrB,YAAQ,QAAQ;AAChB,QAAI,IAAI,KAAK,KAAK;AAAA,EACtB;AACA,SAAO;AACX;AAEO,SAAS,eAAe,MAAwB;AACnD,MAAI,YAAY,IAAI,IAAI,GAAG;AACvB,WAAO,GAAG,IAAI;AAAA,EAClB;AACA,SAAO;AACX;AAEO,IAAK,WAAL,kBAAKC,cAAL;AACH,EAAAA,UAAA,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WAAO,KAAK,YAAY,QAAQ;AAAA,EACpC;AAAA,EAEA,MAAyB,MAAyB;AAC9C,WAAO,KAAK,YAAY,QAAQ;AAAA,EACpC;AAAA,EAEA,MAAyB,OAA0B;AAC/C,WAAO,KAAK,YAAY,QAAQ;AAAA,EACpC;AAAA,EAEA,MAAyB,QAA2B;AAChD,WAAO,KAAK,YAAY,QAAQ;AAAA,EACpC;AAAA,EAEA,MAAyB,SAA4B;AACjD,WAAO,KAAK,YAAY,QAAQ;AAAA,EACpC;AACJ;","names":["StatusCodes","Method","MimeType"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/common.ts","../src/response.ts","../src/basic-worker.ts","../src/routes.ts","../src/routed-worker.ts"],"sourcesContent":["/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { StatusCodes } from \"http-status-codes\";\n\nexport * from \"./basic-worker\";\nexport * from \"./common\";\nexport * from \"./response\";\nexport * from \"./routes\";\nexport * from \"./routed-worker\";\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const Time = {\n Second: 1,\n Minute: 60,\n Hour: 60 * 60,\n Day: 60 * 60 * 24,\n Week: 60 * 60 * 24 * 7,\n} as const;\n\nexport enum Method {\n GET = \"GET\",\n PUT = \"PUT\",\n POST = \"POST\",\n PATCH = \"PATCH\",\n DELETE = \"DELETE\",\n HEAD = \"HEAD\",\n OPTIONS = \"OPTIONS\",\n}\n\nconst METHOD_SET: Set<string> = new Set(Object.values(Method));\n\nexport function isMethod(value: string): value is Method {\n return METHOD_SET.has(value);\n}\n\nexport function getContentType(type: MimeType): string {\n if (ADD_CHARSET.has(type)) {\n return `${type}; charset=utf-8`;\n }\n return type;\n}\n\nexport enum MimeType {\n PLAIN_TEXT = \"text/plain\",\n HTML = \"text/html\",\n CSS = \"text/css\",\n CSV = \"text/csv\",\n XML = \"text/xml\",\n MARKDOWN = \"text/markdown\",\n RICH_TEXT = \"text/richtext\",\n JSON = \"application/json\",\n XML_APP = \"application/xml\",\n YAML = \"application/x-yaml\",\n FORM_URLENCODED = \"application/x-www-form-urlencoded\",\n NDJSON = \"application/x-ndjson\",\n MSGPACK = \"application/x-msgpack\",\n PROTOBUF = \"application/x-protobuf\",\n MULTIPART_FORM_DATA = \"multipart/form-data\",\n MULTIPART_MIXED = \"multipart/mixed\",\n MULTIPART_ALTERNATIVE = \"multipart/alternative\",\n MULTIPART_DIGEST = \"multipart/digest\",\n MULTIPART_RELATED = \"multipart/related\",\n MULTIPART_SIGNED = \"multipart/signed\",\n MULTIPART_ENCRYPTED = \"multipart/encrypted\",\n OCTET_STREAM = \"application/octet-stream\",\n PDF = \"application/pdf\",\n ZIP = \"application/zip\",\n GZIP = \"application/gzip\",\n MSWORD = \"application/msword\",\n DOCX = \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n EXCEL = \"application/vnd.ms-excel\",\n XLSX = \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n POWERPOINT = \"application/vnd.ms-powerpoint\",\n PPTX = \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n ICO = \"image/x-icon\",\n ICO_MS = \"image/vnd.microsoft.icon\",\n GIF = \"image/gif\",\n PNG = \"image/png\",\n JPEG = \"image/jpeg\",\n WEBP = \"image/webp\",\n SVG = \"image/svg+xml\",\n HEIF = \"image/heif\",\n AVIF = \"image/avif\",\n EVENT_STREAM = \"text/event-stream\",\n TAR = \"application/x-tar\",\n BZIP2 = \"application/x-bzip2\",\n}\n\nconst ADD_CHARSET: Set<MimeType> = new Set([\n MimeType.PLAIN_TEXT,\n MimeType.HTML,\n MimeType.CSS,\n MimeType.CSV,\n MimeType.MARKDOWN,\n MimeType.XML,\n MimeType.JSON,\n MimeType.XML_APP,\n MimeType.FORM_URLENCODED,\n MimeType.NDJSON,\n MimeType.RICH_TEXT,\n MimeType.SVG,\n]);\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getReasonPhrase, StatusCodes } from \"http-status-codes\";\nimport { getContentType, Method, MimeType } from \"./common\";\n\nexport interface CorsProvider {\n getOrigin(): string | null;\n getAllowOrigins(): string[];\n getAllowMethods(): Method[];\n getAllowHeaders(): string[];\n getMaxAge(): number;\n}\n\nexport interface ErrorJson {\n code: number;\n error: string;\n details: string;\n}\n\nexport class WorkerResponse {\n private _headers: Headers = new Headers();\n private _body: BodyInit | null;\n\n constructor(\n protected readonly cors: CorsProvider,\n content: BodyInit | null = null,\n protected readonly code: StatusCodes = StatusCodes.OK,\n protected readonly mimeType: MimeType = MimeType.JSON\n ) {\n this._body = this.code === StatusCodes.NO_CONTENT ? null : content;\n }\n\n public createResponse(): Response {\n this.addCorsHeaders();\n if (this.body) {\n this.headers.set(\"Content-Type\", getContentType(this.mimeType));\n }\n return new Response(this.body, this.responseInit);\n }\n\n protected get responseInit(): ResponseInit {\n return {\n headers: this.headers,\n status: this.code,\n statusText: getReasonPhrase(this.code),\n };\n }\n\n protected get body(): BodyInit | null {\n return this._body;\n }\n\n protected get headers(): Headers {\n return this._headers;\n }\n\n protected set headers(headers: Headers) {\n this._headers = headers;\n }\n\n protected addCorsHeaders(): void {\n const origin = this.cors.getOrigin();\n if (!origin) return; // no Origin, skip CORS\n\n if (this.getAllowOrigins().includes(\"*\")) {\n this.headers.set(\"Access-Control-Allow-Origin\", \"*\");\n } else if (this.getAllowOrigins().includes(origin)) {\n this.headers.set(\"Access-Control-Allow-Origin\", origin);\n this.headers.set(\"Access-Control-Allow-Credentials\", \"true\");\n this.headers.set(\"Vary\", \"Origin\");\n }\n this.headers.set(\"Access-Control-Allow-Headers\", this.getAllowHeaders());\n this.headers.set(\"Access-Control-Allow-Methods\", this.getAllowMethods());\n this.headers.set(\"Access-Control-Max-Age\", this.getMaxAge());\n this.headers.set(\"X-Content-Type-Options\", \"nosniff\");\n }\n\n protected getAllowMethods(): string {\n return this.cors.getAllowMethods().join(\", \");\n }\n\n protected getAllowHeaders(): string {\n return this.cors.getAllowHeaders().join(\", \");\n }\n\n protected getAllowOrigins(): string[] {\n return this.cors.getAllowOrigins();\n }\n\n protected getMaxAge(): string {\n return String(this.cors.getMaxAge());\n }\n}\n\nexport class JsonResponse extends WorkerResponse {\n private _json: object;\n constructor(cors: CorsProvider, content: object = {}, code: StatusCodes = StatusCodes.OK) {\n super(cors, null, code, MimeType.JSON);\n this._json = content;\n }\n\n public get json(): object {\n return this._json;\n }\n\n public set json(json: object) {\n this._json = json;\n }\n\n protected override get body(): string {\n return JSON.stringify(this.json);\n }\n}\n\nexport class HtmlResponse extends WorkerResponse {\n constructor(\n cors: CorsProvider,\n content: string,\n code: StatusCodes = StatusCodes.OK,\n type: MimeType = MimeType.HTML\n ) {\n super(cors, content, code, type);\n }\n}\n\nexport class TextResponse extends WorkerResponse {\n constructor(\n cors: CorsProvider,\n content: string,\n code: StatusCodes = StatusCodes.OK,\n type: MimeType = MimeType.PLAIN_TEXT\n ) {\n super(cors, content, code, type);\n }\n}\n\n/**\n * Remove the body from a GET response.\n */\nexport class Head extends WorkerResponse {\n constructor(cors: CorsProvider, response: Response) {\n super(cors, null, response.status);\n this.headers = new Headers(response.headers);\n }\n}\n\nexport class Options extends WorkerResponse {\n constructor(cors: CorsProvider) {\n super(cors, null, StatusCodes.NO_CONTENT);\n this.headers.set(\"Allow\", this.getAllowMethods());\n }\n}\n\nexport class HttpError extends JsonResponse {\n constructor(cors: CorsProvider, code: StatusCodes, protected details?: string) {\n super(cors, {}, code);\n }\n\n public override get json(): ErrorJson {\n return {\n code: this.code,\n error: getReasonPhrase(this.code),\n details: this.details ?? getReasonPhrase(this.code),\n };\n }\n}\n\nexport class BadRequest extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.BAD_REQUEST, detail);\n }\n}\n\nexport class Unauthorized extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.UNAUTHORIZED, detail);\n }\n}\n\nexport class Forbidden extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.FORBIDDEN, detail);\n }\n}\n\nexport class NotFound extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.NOT_FOUND, detail);\n }\n}\n\nexport class MethodNotAllowed extends HttpError {\n constructor(cors: CorsProvider, method: string) {\n super(cors, StatusCodes.METHOD_NOT_ALLOWED, `${method} method not allowed.`);\n this.headers.set(\"Allow\", this.getAllowMethods());\n }\n\n public override get json(): ErrorJson & { allowed: Method[] } {\n return {\n ...super.json,\n allowed: this.cors.getAllowMethods(),\n };\n }\n}\n\nexport class InternalServerError extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.INTERNAL_SERVER_ERROR, detail);\n }\n}\n\nexport class NotImplemented extends HttpError {\n constructor(cors: CorsProvider) {\n super(cors, StatusCodes.NOT_IMPLEMENTED);\n }\n}\n\nexport class ServiceUnavailable extends HttpError {\n constructor(cors: CorsProvider, detail?: string) {\n super(cors, StatusCodes.SERVICE_UNAVAILABLE, detail);\n }\n}\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { isMethod, Method, Time } from \"./common\";\nimport {\n CorsProvider,\n Head,\n InternalServerError,\n MethodNotAllowed,\n NotImplemented,\n Options,\n WorkerResponse,\n} from \"./response\";\n\nexport abstract class BasicWorker implements CorsProvider {\n constructor(\n private readonly _request: Request,\n private readonly _env: Env = {},\n private readonly _ctx?: ExecutionContext\n ) {}\n\n protected get request(): Request {\n return this._request;\n }\n\n protected get env(): Env {\n return this._env;\n }\n\n protected get ctx(): ExecutionContext | undefined {\n return this._ctx;\n }\n\n public async fetch(): Promise<Response> {\n if (!this.isAllowed(this.request.method)) {\n return this.getResponse(MethodNotAllowed, this.request.method);\n }\n\n try {\n return await this.dispatch(this.request);\n } catch (error) {\n return this.getResponse(InternalServerError, String(error));\n }\n }\n\n protected async dispatch(request: Request): Promise<Response> {\n const method = request.method as Method;\n const handler: Record<Method, () => Promise<Response>> = {\n GET: () => this.get(),\n PUT: () => this.put(),\n POST: () => this.post(),\n PATCH: () => this.patch(),\n DELETE: () => this.delete(),\n HEAD: () => this.head(),\n OPTIONS: () => this.options(),\n };\n return (handler[method] ?? (() => this.getResponse(MethodNotAllowed, method)))();\n }\n\n protected async get(): Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected async put(): Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected async post(): Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected async patch(): Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected async delete(): Promise<Response> {\n return this.getResponse(NotImplemented);\n }\n\n protected async options(): Promise<Response> {\n return this.getResponse(Options);\n }\n\n protected async head(): Promise<Response> {\n // Dispatch a new GET request created from the HEAD request \n // and return the GET response with the body removed.\n return this.getResponse(\n Head,\n await this.dispatch(new Request(this.request, { method: Method.GET }))\n );\n }\n\n protected getResponse<\n T extends WorkerResponse,\n Ctor extends new (cors: CorsProvider, ...args: any[]) => T\n >(\n ResponseClass: Ctor,\n ...args: ConstructorParameters<Ctor> extends [any, ...infer R] ? R : never\n ): Response {\n return new ResponseClass(this, ...args).createResponse();\n }\n\n public isAllowed(method: string): boolean {\n return isMethod(method) && this.getAllowMethods().includes(method);\n }\n\n public getAllowOrigins(): string[] {\n return [\"*\"];\n }\n\n public getAllowMethods(): Method[] {\n return [Method.GET, Method.OPTIONS, Method.HEAD];\n }\n\n public getAllowHeaders(): string[] {\n return [\"Content-Type\"];\n }\n\n public getMaxAge(): number {\n return Time.Week;\n }\n\n public getOrigin(): string | null {\n return this.request.headers.get(\"Origin\");\n }\n}\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Method } from \"./common\";\n\nexport type RouteCallback = (...matches: string[]) => Response | Promise<Response>;\n\nexport type RouteInit = [Method, string, RouteCallback];\n\nexport class Route {\n public readonly pattern: RegExp;\n\n constructor(pattern: RegExp | string, public readonly callback: RouteCallback) {\n this.pattern = new RegExp(pattern);\n }\n}\n\nexport class Routes {\n private readonly map = new Map<Method, Route[]>();\n\n public add(method: Method, route: Route) {\n const existing = this.map.get(method);\n if (existing) {\n existing.push(route);\n } else {\n this.map.set(method, [route]);\n }\n return this;\n }\n\n public get(method: Method, url: string): Route | undefined {\n const routes = this.map.get(method);\n if (!routes) return undefined;\n\n const pathname = new URL(url).pathname;\n return routes.find(({ pattern }) => pattern.test(pathname));\n }\n}\n","/*\n * Copyright (C) 2025 Ty Busby\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { BasicWorker } from \"./basic-worker\";\nimport { Method } from \"./common\";\nimport { NotFound } from \"./response\";\nimport { Route, Routes, RouteInit, RouteCallback } from \"./routes\";\n\nexport abstract class RoutedWorker extends BasicWorker {\n private readonly routes: Routes = new Routes();\n\n protected initialize(routes: RouteInit[]) {\n routes.forEach(([method, pattern, callback]) => {\n this.add(method, pattern, callback);\n });\n }\n\n protected add(method: Method, pattern: string, callback: RouteCallback) {\n this.routes.add(method, new Route(pattern, callback));\n return this;\n }\n\n protected async dispatch(request: Request): Promise<Response> {\n const route = this.routes.get(request.method as Method, request.url);\n if (!route) return super.dispatch(request);\n\n const match = new URL(request.url).pathname.match(route.pattern) ?? [];\n return route.callback.call(this, ...match);\n }\n\n protected override async get(): Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override async put(): Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override async post(): Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override async patch(): Promise<Response> {\n return this.getResponse(NotFound);\n }\n\n protected override async delete(): Promise<Response> {\n return this.getResponse(NotFound);\n }\n}\n"],"mappings":";AA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loud-spark",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"description": "Ignite your Cloudflare Workers with a type-safe library for rapid development.",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Ty Busby",
|
|
7
|
+
"email": "tybusby@adonix.org",
|
|
8
|
+
"url": "https://www.adonix.org"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"cloudflare",
|
|
12
|
+
"workers",
|
|
13
|
+
"typescript"
|
|
14
|
+
],
|
|
15
|
+
"license": "Apache-2.0",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/adonix-org/cloud-spark"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"email": "support@adonix.org",
|
|
22
|
+
"url": "https://github.com/adonix-org/cloud-spark/issues"
|
|
23
|
+
},
|
|
5
24
|
"type": "module",
|
|
6
25
|
"main": "./dist/index.js",
|
|
7
26
|
"module": "./dist/index.js",
|
|
@@ -28,7 +47,7 @@
|
|
|
28
47
|
"tsup": "^8.5.0",
|
|
29
48
|
"tsx": "^4.20.4",
|
|
30
49
|
"typescript": "^5.9.2",
|
|
31
|
-
"vitest": "
|
|
50
|
+
"vitest": "^3.2.4"
|
|
32
51
|
},
|
|
33
52
|
"dependencies": {
|
|
34
53
|
"http-status-codes": "^2.3.0"
|