edge.libx.js 0.0.6 → 0.0.7
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/bin/set-secrets.ts
CHANGED
|
@@ -16,23 +16,24 @@ try {
|
|
|
16
16
|
const lines = fileContents.split('\n');
|
|
17
17
|
|
|
18
18
|
for (const line of lines) {
|
|
19
|
-
if (!line.trim() || line.startsWith('#')) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
if (!line.trim() || line.trim().startsWith('#')) {
|
|
20
|
+
const glimpse = line.substring(0, 10);
|
|
21
|
+
console.log(`Skipping comment or empty line: ${glimpse}...`);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const firstEqualIndex = line.indexOf('=');
|
|
26
|
+
if (firstEqualIndex === -1) {
|
|
27
|
+
console.log(`Skipping invalid line: ${line}`);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
const key = line.substring(0, firstEqualIndex).trim();
|
|
32
|
+
const rawValue = line.substring(firstEqualIndex + 1).trim();
|
|
33
|
+
// Escape double quotes in the value
|
|
34
|
+
let value = rawValue.replace(/"/g, '\\"');
|
|
35
|
+
value = rawValue.replace(/"/g, '\\"');
|
|
36
|
+
value = rawValue.replace(/\s*#.*/g, '');
|
|
36
37
|
|
|
37
38
|
console.log(`Processing key: ${key}`);
|
|
38
39
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterWrapper.js","sourceRoot":"","sources":["../../src/modules/RouterWrapper.ts"],"names":[],"mappings":";;;;AAAA,uEAA2D;AAC3D,6CAAwH;AACxH,gDAA0D;AAI1D,MAAa,aAAa;IAKzB,YAA0B,IAAY,EAAS,MAA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C,CAAC;IACrF,CAAC;IAEM,aAAa;QACnB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,IAAA,mBAAK,EAAC,GAAG,CAAC,CAAC,CAAC;IACxC,CAAC;IAEM,mBAAmB;QACzB,MAAM,UAAU,GAAG,IAAA,4BAAmB,EAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACrE,OAAO,UAAU,CAAC;IACnB,CAAC;;AA5DF,sCA6DC;;AA5De,kBAAI,GAAG,IAAA,kBAAI,EAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,AAAlD,CAAmD;AACvD,uBAAS,GAAG,EAAI,CAAC,IAAI,CAAC,SAAS,AAAtB,CAAuB;AAChC,qBAAO,GAAG,EAAI,CAAC,IAAI,CAAC,OAAO,AAApB,CAAqB","sourcesContent":["import { libx } from 'libx.js/build/bundles/essentials.js';\nimport { Route, Router, RouterType, error, json, cors, withParams, IRequest, text, ResponseHandler } from 'itty-router';\nimport { createServerAdapter } from '@whatwg-node/server';\n\ntype BaseRouterInitializer = (string) => { base: string; router: RouterType<IRequest, any[]> };\n\nexport class RouterWrapper<TCtx = any> {\n\tprivate static cors = cors({ origin: ['*'], allowMethods: ['POST'] });\n\tprivate static preflight = this.cors.preflight;\n\tprivate static corsify = this.cors.corsify;\n\n\tpublic constructor(public base: string, public router: RouterType<Request, [], any>) {\n\n\t}\n\n\tprivate static tryCors(response, request): Response {\n\t\ttry {\n\t\t\treturn this.corsify(response, request);\n\t\t} catch (err) {\n libx.log.w('tryCors: failed to perform CORS', err);\n }\n\t}\n\n\tpublic static getNew(base: string) {\n\t\tconst router = Router({\n base,\n before: [this.preflight],\n catch: this.errorHandler,\n // finally: [this.tryCors],\n });\n\t\trouter.all('*', withParams);\n\t\t// router.finally.push(this.corsify);\n\n\t\t// router.all('*', () => error(404));\n\n\t\treturn new RouterWrapper(base, router);\n\t}\n\n\n\tpublic static errorHandler(error) {\n\t\tconst isObject = libx.isObject(error);\n\t\tconst errMessage = error?.message ?? error;\n\t\tconst msg = 'Error: ' + (!isObject ? (errMessage ?? 'Server Error') : JSON.stringify(error));\n\t\tconst status = parseInt(error?.status ?? error?.statusCode ?? error?.code ?? error?.error?.code) || 500;\n\t\tconsole.error('Server error: ', error, status);\n\t\treturn new Response(msg, { status })\n\t}\n\n\tpublic registerRoute(newBase: string, baseRouterInitializer: BaseRouterInitializer) {\n\t\tconst route = baseRouterInitializer(`${this.base}${newBase}`);\n\t\tthis.router.all(newBase + '/*', route.router.fetch);\n\t\treturn this.router;\n\t};\n\n\tpublic fetchHandler(request: IRequest, ctx: TCtx) {\n\t\t// return this.router.fetch(request, ctx).then(json).then(RouterWrapper.corsify).catch(this.errorHandler);\n\t\treturn this.router.fetch(request, ctx).then(json).catch(RouterWrapper.errorHandler);\n\t}\n\n\tpublic catchNotFound() {\n\t\tthis.router.all('*', () => error(404));\n\t}\n\n\tpublic createServerAdapter() {\n\t\tconst ittyServer = createServerAdapter(this.fetchHandler.bind(this));\n\t\treturn ittyServer;\n\t}\n}"]}
|
package/package.json
CHANGED
|
@@ -17,17 +17,17 @@ export class RouterWrapper<TCtx = any> {
|
|
|
17
17
|
try {
|
|
18
18
|
return this.corsify(response, request);
|
|
19
19
|
} catch (err) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
libx.log.w('tryCors: failed to perform CORS', err);
|
|
21
|
+
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
public static getNew(base: string) {
|
|
25
25
|
const router = Router({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
base,
|
|
27
|
+
before: [this.preflight],
|
|
28
|
+
catch: this.errorHandler,
|
|
29
|
+
// finally: [this.tryCors],
|
|
30
|
+
});
|
|
31
31
|
router.all('*', withParams);
|
|
32
32
|
// router.finally.push(this.corsify);
|
|
33
33
|
|