@bepalo/spine 1.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.
- package/LICENSE +21 -0
- package/README.md +830 -0
- package/dist/auth-middlewares.d.ts +119 -0
- package/dist/auth-middlewares.d.ts.map +1 -0
- package/dist/auth-middlewares.js +168 -0
- package/dist/auth-middlewares.js.map +1 -0
- package/dist/cjs/auth-middlewares.d.ts +119 -0
- package/dist/cjs/auth-middlewares.d.ts.map +1 -0
- package/dist/cjs/auth-middlewares.js +168 -0
- package/dist/cjs/auth-middlewares.js.map +1 -0
- package/dist/cjs/helpers.d.ts +180 -0
- package/dist/cjs/helpers.d.ts.map +1 -0
- package/dist/cjs/helpers.js +366 -0
- package/dist/cjs/helpers.js.map +1 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +30 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/middlewares.d.ts +88 -0
- package/dist/cjs/middlewares.d.ts.map +1 -0
- package/dist/cjs/middlewares.js +262 -0
- package/dist/cjs/middlewares.js.map +1 -0
- package/dist/cjs/parsers.d.ts +177 -0
- package/dist/cjs/parsers.d.ts.map +1 -0
- package/dist/cjs/parsers.js +1021 -0
- package/dist/cjs/parsers.js.map +1 -0
- package/dist/cjs/router.d.ts +124 -0
- package/dist/cjs/router.d.ts.map +1 -0
- package/dist/cjs/router.js +1378 -0
- package/dist/cjs/router.js.map +1 -0
- package/dist/cjs/status.d.ts +77 -0
- package/dist/cjs/status.d.ts.map +1 -0
- package/dist/cjs/status.js +252 -0
- package/dist/cjs/status.js.map +1 -0
- package/dist/cjs/types.d.ts +135 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +109 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils.d.ts +11 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +76 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/cjs/utils.node.d.ts +4 -0
- package/dist/cjs/utils.node.d.ts.map +1 -0
- package/dist/cjs/utils.node.js +99 -0
- package/dist/cjs/utils.node.js.map +1 -0
- package/dist/helpers.d.ts +180 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +366 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/middlewares.d.ts +88 -0
- package/dist/middlewares.d.ts.map +1 -0
- package/dist/middlewares.js +262 -0
- package/dist/middlewares.js.map +1 -0
- package/dist/parsers.d.ts +177 -0
- package/dist/parsers.d.ts.map +1 -0
- package/dist/parsers.js +1021 -0
- package/dist/parsers.js.map +1 -0
- package/dist/router.d.ts +124 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +1378 -0
- package/dist/router.js.map +1 -0
- package/dist/status.d.ts +77 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +252 -0
- package/dist/status.js.map +1 -0
- package/dist/types.d.ts +135 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +109 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +76 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.node.d.ts +4 -0
- package/dist/utils.node.d.ts.map +1 -0
- package/dist/utils.node.js +66 -0
- package/dist/utils.node.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpError = exports.RouterError = exports.MIME_TYPES = exports.Break_Pipe = exports.Break_Pipeline = void 0;
|
|
4
|
+
// Symbol used to signal breaking from all handler pipeline in queue
|
|
5
|
+
exports.Break_Pipeline = Symbol("Break_Pipeline");
|
|
6
|
+
// Symbol used to signal breaking from current handler pipeline in queue but not others
|
|
7
|
+
exports.Break_Pipe = Symbol("Break_Pipe");
|
|
8
|
+
exports.MIME_TYPES = new Map([
|
|
9
|
+
["aac", "audio/aac"],
|
|
10
|
+
["abw", "application/x-abiword"],
|
|
11
|
+
["apng", "image/apng"],
|
|
12
|
+
["arc", "application/x-freearc"],
|
|
13
|
+
["avif", "image/avif"],
|
|
14
|
+
["avi", "video/x-msvideo"],
|
|
15
|
+
["azw", "application/vnd.amazon.ebook"],
|
|
16
|
+
["bin", "application/octet-stream"],
|
|
17
|
+
["bmp", "image/bmp"],
|
|
18
|
+
["bz", "application/x-bzip"],
|
|
19
|
+
["bz2", "application/x-bzip2"],
|
|
20
|
+
["cda", "application/x-cdf"],
|
|
21
|
+
["csh", "application/x-csh"],
|
|
22
|
+
["css", "text/css"],
|
|
23
|
+
["csv", "text/csv"],
|
|
24
|
+
["doc", "application/msword"],
|
|
25
|
+
[
|
|
26
|
+
"docx",
|
|
27
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
28
|
+
],
|
|
29
|
+
["eot", "application/vnd.ms-fontobject"],
|
|
30
|
+
["epub", "application/epub+zip"],
|
|
31
|
+
["gz", "application/gzip"],
|
|
32
|
+
["gif", "image/gif"],
|
|
33
|
+
["htm", "text/html"],
|
|
34
|
+
["html", "text/html"],
|
|
35
|
+
["ico", "image/vnd.microsoft.icon"],
|
|
36
|
+
["ics", "text/calendar"],
|
|
37
|
+
["jar", "application/java-archive"],
|
|
38
|
+
["jpeg", "image/jpeg"],
|
|
39
|
+
["jpg", "image/jpeg"],
|
|
40
|
+
["js", "text/javascript"],
|
|
41
|
+
["json", "application/json"],
|
|
42
|
+
["jsonld", "application/ld+json"],
|
|
43
|
+
["md", "text/markdown"],
|
|
44
|
+
["mid", "audio/midi"],
|
|
45
|
+
["midi", "audio/midi"],
|
|
46
|
+
["mjs", "text/javascript"],
|
|
47
|
+
["m4a", "audio/mp4"],
|
|
48
|
+
["mp3", "audio/mpeg"],
|
|
49
|
+
["mp4", "video/mp4"],
|
|
50
|
+
["mpeg", "video/mpeg"],
|
|
51
|
+
["mpkg", "application/vnd.apple.installer+xml"],
|
|
52
|
+
["odp", "application/vnd.oasis.opendocument.presentation"],
|
|
53
|
+
["ods", "application/vnd.oasis.opendocument.spreadsheet"],
|
|
54
|
+
["odt", "application/vnd.oasis.opendocument.text"],
|
|
55
|
+
["oga", "audio/ogg"],
|
|
56
|
+
["ogv", "video/ogg"],
|
|
57
|
+
["ogx", "application/ogg"],
|
|
58
|
+
["opus", "audio/ogg"],
|
|
59
|
+
["otf", "font/otf"],
|
|
60
|
+
["png", "image/png"],
|
|
61
|
+
["pdf", "application/pdf"],
|
|
62
|
+
["php", "application/x-httpd-php"],
|
|
63
|
+
["ppt", "application/vnd.ms-powerpoint"],
|
|
64
|
+
[
|
|
65
|
+
"pptx",
|
|
66
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
67
|
+
],
|
|
68
|
+
["rar", "application/vnd.rar"],
|
|
69
|
+
["rtf", "application/rtf"],
|
|
70
|
+
["sh", "application/x-sh"],
|
|
71
|
+
["svg", "image/svg+xml"],
|
|
72
|
+
["tar", "application/x-tar"],
|
|
73
|
+
["tif", "image/tiff"],
|
|
74
|
+
["tiff", "image/tiff"],
|
|
75
|
+
["ts", "video/mp2t"],
|
|
76
|
+
["ttf", "font/ttf"],
|
|
77
|
+
["txt", "text/plain"],
|
|
78
|
+
["vsd", "application/vnd.visio"],
|
|
79
|
+
["wav", "audio/wav"],
|
|
80
|
+
["weba", "audio/webm"],
|
|
81
|
+
["webm", "video/webm"],
|
|
82
|
+
["webmanifest", "application/manifest+json"],
|
|
83
|
+
["webp", "image/webp"],
|
|
84
|
+
["woff", "font/woff"],
|
|
85
|
+
["woff2", "font/woff2"],
|
|
86
|
+
["xhtml", "application/xhtml+xml"],
|
|
87
|
+
["xls", "application/vnd.ms-excel"],
|
|
88
|
+
["xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
|
|
89
|
+
["xml", "application/xml"],
|
|
90
|
+
["xul", "application/vnd.mozilla.xul+xml"],
|
|
91
|
+
["zip", "application/zip"],
|
|
92
|
+
["3gp", "video/3gpp"],
|
|
93
|
+
["3g2", "video/3gpp2"],
|
|
94
|
+
["7z", "application/x-7z-compressed"],
|
|
95
|
+
]);
|
|
96
|
+
class RouterError extends Error {
|
|
97
|
+
constructor(message, options) {
|
|
98
|
+
super(message, options);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.RouterError = RouterError;
|
|
102
|
+
class HttpError extends Error {
|
|
103
|
+
constructor(status, message, options) {
|
|
104
|
+
super(message, options);
|
|
105
|
+
this.status = status;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.HttpError = HttpError;
|
|
109
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAAA,oEAAoE;AACvD,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACvD,uFAAuF;AAC1E,QAAA,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAiHlC,QAAA,UAAU,GAAG,IAAI,GAAG,CAAmB;IAClD,CAAC,KAAK,EAAE,WAAW,CAAC;IACpB,CAAC,KAAK,EAAE,uBAAuB,CAAC;IAChC,CAAC,MAAM,EAAE,YAAY,CAAC;IACtB,CAAC,KAAK,EAAE,uBAAuB,CAAC;IAChC,CAAC,MAAM,EAAE,YAAY,CAAC;IACtB,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAC1B,CAAC,KAAK,EAAE,8BAA8B,CAAC;IACvC,CAAC,KAAK,EAAE,0BAA0B,CAAC;IACnC,CAAC,KAAK,EAAE,WAAW,CAAC;IACpB,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAC5B,CAAC,KAAK,EAAE,qBAAqB,CAAC;IAC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,iBAAiB,CAAC;IAC1B,CAAC,KAAK,EAAE,YAAY,CAAC;IACrB,CAAC,KAAK,EAAE,aAAa,CAAC;IACtB,CAAC,IAAI,EAAE,6BAA6B,CAAC;CACtC,CAAC,CAAC;AAgJH,MAAa,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe,EAAE,OAAsB;QACjD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;CACF;AAJD,kCAIC;AAED,MAAa,SAAU,SAAQ,KAAK;IAClC,YACS,MAAc,EACrB,OAAe,EACf,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAJjB,WAAM,GAAN,MAAM,CAAQ;IAKvB,CAAC;CACF;AARD,8BAQC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface DirWalkNode {
|
|
2
|
+
type: string;
|
|
3
|
+
name: string;
|
|
4
|
+
path: string;
|
|
5
|
+
parent: string;
|
|
6
|
+
fullPath: string;
|
|
7
|
+
relativePath: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const toBase64UUID: (u: string) => string;
|
|
10
|
+
export declare const fromBase64UUID: (cuuid: string) => string;
|
|
11
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAsBD,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,KAAG,MA4BxC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,KAAG,MAyB9C,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromBase64UUID = exports.toBase64UUID = void 0;
|
|
4
|
+
const CCPlus = 43; // "+".charCodeAt(0);
|
|
5
|
+
const CCFSlash = 47; // "/".charCodeAt(0);
|
|
6
|
+
const CCEqual = 61; // "=".charCodeAt(0);
|
|
7
|
+
const CCMinus = 45; // "-".charCodeAt(0);
|
|
8
|
+
const CCUnderScore = 95; // "_".charCodeAt(0);
|
|
9
|
+
const CC0 = 48; // "0".charCodeAt(0);
|
|
10
|
+
const CC9 = 57; // "9".charCodeAt(0);
|
|
11
|
+
const CCa_offset10 = 87; // "a".charCodeAt(0) - 10;
|
|
12
|
+
const HEXMAP = "0123456789abcdef";
|
|
13
|
+
const h = (b, index) => {
|
|
14
|
+
const cc = b.charCodeAt(index);
|
|
15
|
+
return HEXMAP[cc >> 4] + HEXMAP[cc & 15];
|
|
16
|
+
};
|
|
17
|
+
const hb = (c) => (c <= CC9 ? c - CC0 : c - CCa_offset10);
|
|
18
|
+
const b = (h, i) => String.fromCharCode((hb(h.charCodeAt(i)) << 4) | hb(h.charCodeAt(i + 1)));
|
|
19
|
+
const toBase64UUID = (u) => {
|
|
20
|
+
const binary = `${b(u, 0)}${b(u, 2)}${b(u, 4)}${b(u, 6)}${b(u, 9)}${b(u, 11)}${b(u, 14)}${b(u, 16)}${b(u, 19)}${b(u, 21)}${b(u, 24)}${b(u, 26)}${b(u, 28)}${b(u, 30)}${b(u, 32)}${b(u, 34)}`;
|
|
21
|
+
const base64 = btoa(binary);
|
|
22
|
+
let base64Url = "";
|
|
23
|
+
let lastI = 0;
|
|
24
|
+
const base64Len = base64.length;
|
|
25
|
+
for (let i = 0; i < base64Len;) {
|
|
26
|
+
const cc = base64.charCodeAt(i);
|
|
27
|
+
switch (cc) {
|
|
28
|
+
case CCPlus:
|
|
29
|
+
base64Url += base64.substring(lastI, i) + "-";
|
|
30
|
+
lastI = ++i;
|
|
31
|
+
break;
|
|
32
|
+
case CCFSlash:
|
|
33
|
+
base64Url += base64.substring(lastI, i) + "_";
|
|
34
|
+
lastI = ++i;
|
|
35
|
+
break;
|
|
36
|
+
case CCEqual:
|
|
37
|
+
base64Url += base64.substring(lastI, i);
|
|
38
|
+
return base64Url;
|
|
39
|
+
default:
|
|
40
|
+
i++;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (lastI < base64Len) {
|
|
44
|
+
base64Url += base64.substring(lastI);
|
|
45
|
+
}
|
|
46
|
+
return base64Url;
|
|
47
|
+
};
|
|
48
|
+
exports.toBase64UUID = toBase64UUID;
|
|
49
|
+
const fromBase64UUID = (cuuid) => {
|
|
50
|
+
let base64 = "";
|
|
51
|
+
let lastI = 0;
|
|
52
|
+
const cuuidLen = cuuid.length;
|
|
53
|
+
for (let i = 0; i < cuuidLen;) {
|
|
54
|
+
const cc = cuuid.charCodeAt(i);
|
|
55
|
+
switch (cc) {
|
|
56
|
+
case CCMinus:
|
|
57
|
+
base64 += cuuid.substring(lastI, i) + "+";
|
|
58
|
+
lastI = ++i;
|
|
59
|
+
break;
|
|
60
|
+
case CCUnderScore:
|
|
61
|
+
base64 += cuuid.substring(lastI, i) + "/";
|
|
62
|
+
lastI = ++i;
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
i++;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (lastI < cuuidLen) {
|
|
69
|
+
base64 += cuuid.substring(lastI);
|
|
70
|
+
}
|
|
71
|
+
const b = atob(base64);
|
|
72
|
+
const uuid = `${h(b, 0)}${h(b, 1)}${h(b, 2)}${h(b, 3)}-${h(b, 4)}${h(b, 5)}-${h(b, 6)}${h(b, 7)}-${h(b, 8)}${h(b, 9)}-${h(b, 10)}${h(b, 11)}${h(b, 12)}${h(b, 13)}${h(b, 14)}${h(b, 15)}`;
|
|
73
|
+
return uuid;
|
|
74
|
+
};
|
|
75
|
+
exports.fromBase64UUID = fromB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O,MAAM,aAAa,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,OAAO,CAErE,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
45
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
46
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
47
|
+
var m = o[Symbol.asyncIterator], i;
|
|
48
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
49
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
50
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
51
|
+
};
|
|
52
|
+
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
|
53
|
+
var i, p;
|
|
54
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
55
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
|
56
|
+
};
|
|
57
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
58
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
59
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
60
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
61
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
62
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
63
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
64
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
65
|
+
function fulfill(value) { resume("next", value); }
|
|
66
|
+
function reject(value) { resume("throw", value); }
|
|
67
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
exports.dynamicImport = void 0;
|
|
71
|
+
exports.walk = walk;
|
|
72
|
+
const promises_1 = require("node:fs/promises");
|
|
73
|
+
const node_path_1 = require("node:path");
|
|
74
|
+
function walk(dir, rootPath) {
|
|
75
|
+
return __asyncGenerator(this, arguments, function* walk_1() {
|
|
76
|
+
rootPath = rootPath || dir;
|
|
77
|
+
for (const entry of yield __await((0, promises_1.readdir)(dir, {
|
|
78
|
+
withFileTypes: true,
|
|
79
|
+
}))) {
|
|
80
|
+
const name = entry.name;
|
|
81
|
+
const parent = (0, node_path_1.relative)(rootPath, dir).replace(/\\/g, "/");
|
|
82
|
+
const path = (0, node_path_1.join)(dir, name).replace(/\\/g, "/");
|
|
83
|
+
const fullPath = (0, node_path_1.resolve)(dir, name).replace(/\\/g, "/");
|
|
84
|
+
const relativePath = (0, node_path_1.relative)(rootPath, path).replace(/\\/g, "/");
|
|
85
|
+
if (entry.isDirectory()) {
|
|
86
|
+
yield yield __await({ type: "dir", name, path, parent, fullPath, relativePath });
|
|
87
|
+
yield __await(yield* __asyncDelegator(__asyncValues(walk(path, rootPath))));
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
yield yield __await({ type: "file", name, path, parent, fullPath, relativePath });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const dynamicImport = (fullPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
return yield Promise.resolve(`${fullPath}`).then(s => __importStar(require(s)));
|
|
97
|
+
});
|
|
98
|
+
exports.dynamicImport = dynamicImport;
|
|
99
|
+
//# sourceMappingURL=utils.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.node.js","sourceRoot":"","sources":["../../src/utils.node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAoBC;AAvBD,+CAA2C;AAC3C,yCAAoD;AAEpD,SAAuB,IAAI,CACzB,GAAW,EACX,QAAiB;;QAEjB,QAAQ,GAAG,QAAQ,IAAI,GAAG,CAAC;QAC3B,KAAK,MAAM,KAAK,IAAI,cAAM,IAAA,kBAAO,EAAC,GAAG,EAAE;YACrC,aAAa,EAAE,IAAI;SACpB,CAAC,CAAA,EAAE,CAAC;YACH,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;YACxB,MAAM,MAAM,GAAG,IAAA,oBAAQ,EAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC3D,MAAM,IAAI,GAAG,IAAA,gBAAI,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACjD,MAAM,QAAQ,GAAG,IAAA,mBAAO,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YACxD,MAAM,YAAY,GAAG,IAAA,oBAAQ,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAClE,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,oBAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAA,CAAC;gBAClE,cAAA,KAAK,CAAC,CAAC,iBAAA,cAAA,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA,CAAA,CAAA,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACN,oBAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAA,CAAC;YACrE,CAAC;QACH,CAAC;IACH,CAAC;CAAA;AAEM,MAAM,aAAa,GAAG,CAAO,QAAgB,EAAoB,EAAE;IACxE,OAAO,yBAAa,QAAQ,uCAAC,CAAC;AAChC,CAAC,CAAA,CAAC;AAFW,QAAA,aAAa,iBAExB"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import Router from "./router.ts";
|
|
2
|
+
import type { Handler, HttpMethod } from "./types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Response with the specified status code.
|
|
5
|
+
* Defaults to 'text/plain; charset=utf-8' content-type if not provided in init.headers.
|
|
6
|
+
* @param {number} status - The HTTP status code
|
|
7
|
+
* @param {string|null} [content] - The response body content
|
|
8
|
+
* @param {ResponseInit} [init] - Additional response initialization options
|
|
9
|
+
* @returns {Response} A Response object
|
|
10
|
+
* @example
|
|
11
|
+
* status(200, "Success");
|
|
12
|
+
* status(404, "Not Found");
|
|
13
|
+
* status(204, null); // No content response
|
|
14
|
+
*/
|
|
15
|
+
export declare const status: (status: number, content?: string | null, init?: ResponseInit) => Response;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a redirect Response.
|
|
18
|
+
* Defaults to 302 Found unless another status is provided.
|
|
19
|
+
* @param {string} location - The URL to redirect to
|
|
20
|
+
* @param {number} [code=302] - The HTTP status code (301, 302, 303, 307, 308)
|
|
21
|
+
* @param {ResponseInit} [init] - Additional response initialization options
|
|
22
|
+
* @returns {Response} A Response object with Location header
|
|
23
|
+
*/
|
|
24
|
+
export declare const redirect: (location: string, init?: ResponseInit) => Response;
|
|
25
|
+
/**
|
|
26
|
+
* Forwards the request to another route internally.
|
|
27
|
+
* Does not send a redirect to the client but changes the path and method,
|
|
28
|
+
* adds X-Forwarded-[Method|Path] and X-Original-Path headers and calls
|
|
29
|
+
* `(this as Router).respond(newReq, ctx)`.
|
|
30
|
+
* NOTE: parse body only once at the first handler using `parseBody({once: true})`
|
|
31
|
+
* as the body will be consumed at the first parseBody call.
|
|
32
|
+
* @param {Router<ExtendContext>} router - The router instance to forward to
|
|
33
|
+
* @param {string} path - The new path to forward to
|
|
34
|
+
* @returns {Response} A Response object with the forwarded request's response
|
|
35
|
+
*/
|
|
36
|
+
export declare const forward: <ExtendContext extends Record<string, unknown> = Record<string, never>>(router: Router<ExtendContext>, path: `/${string}`, options?: {
|
|
37
|
+
method?: HttpMethod;
|
|
38
|
+
}) => Handler<ExtendContext>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a text/plain Response.
|
|
41
|
+
* Defaults to status 200 and 'text/plain; charset=utf-8' content-type if not specified.
|
|
42
|
+
* @param {string} content - The text content to return
|
|
43
|
+
* @param {ResponseInit} [init] - Additional response initialization options
|
|
44
|
+
* @returns {Response} A Response object with text/plain content-type
|
|
45
|
+
* @example
|
|
46
|
+
* text("Hello, world!");
|
|
47
|
+
* text("Error occurred", { status: 500 });
|
|
48
|
+
*/
|
|
49
|
+
export declare const text: (content: string, init?: ResponseInit) => Response;
|
|
50
|
+
/**
|
|
51
|
+
* Creates an HTML Response.
|
|
52
|
+
* Defaults to status 200 and text/html content-type if not specified.
|
|
53
|
+
* @param {string} content - The HTML content to return
|
|
54
|
+
* @param {ResponseInit} [init] - Additional response initialization options
|
|
55
|
+
* @returns {Response} A Response object with text/html content-type
|
|
56
|
+
* @example
|
|
57
|
+
* html("<h1>Hello</h1>");
|
|
58
|
+
* html("<p>Not Found</p>", { status: 404 });
|
|
59
|
+
*/
|
|
60
|
+
export declare const html: (content: string, init?: ResponseInit) => Response;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a JSON Response.
|
|
63
|
+
* Defaults to status 200 and 'application/json; charset=utf-8' content-type if not specified.
|
|
64
|
+
* Uses Response.json() internally which automatically serializes the body.
|
|
65
|
+
* @param {any} body - The data to serialize as JSON
|
|
66
|
+
* @param {ResponseInit} [init] - Additional response initialization options
|
|
67
|
+
* @returns {Response} A Response object with application/json content-type
|
|
68
|
+
* @example
|
|
69
|
+
* json({ message: "Success" });
|
|
70
|
+
* json({ error: "Not found" }, { status: 404 });
|
|
71
|
+
*/
|
|
72
|
+
export declare const json: (body: any, init?: ResponseInit) => Response;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a Response from a Blob.
|
|
75
|
+
* Automatically sets content-type from blob.type or defaults to application/octet-stream.
|
|
76
|
+
* Also sets content-length header.
|
|
77
|
+
* @param {Blob} blob - The blob data to return
|
|
78
|
+
* @param {ResponseInit} [init] - Additional response initialization options
|
|
79
|
+
* @returns {Response} A Response object with appropriate content-type
|
|
80
|
+
* @example
|
|
81
|
+
* const blob = new Blob(["file content"], { type: "text/plain" });
|
|
82
|
+
* blob(blob);
|
|
83
|
+
*/
|
|
84
|
+
export declare const blob: (blob: Blob, init?: ResponseInit) => Response;
|
|
85
|
+
/**
|
|
86
|
+
* Creates a Response from a Blob or ArrayBuffer with application/octet-stream content-type.
|
|
87
|
+
* Forces octet-stream content-type.
|
|
88
|
+
* Also sets content-length header.
|
|
89
|
+
* @param {Blob|ArrayBuffer} octetStream - The blob data to return
|
|
90
|
+
* @param {ResponseInit} [init] - Additional response initialization options
|
|
91
|
+
* @returns {Response} A Response object with application/octet-stream content-type
|
|
92
|
+
* @example
|
|
93
|
+
* const blob = new Blob([binaryData]);
|
|
94
|
+
* octetStream(blob);
|
|
95
|
+
*/
|
|
96
|
+
export declare const octetStream: (octet: Blob | ArrayBuffer | ReadableStream, init?: ResponseInit) => Response;
|
|
97
|
+
/**
|
|
98
|
+
* Creates a Response from FormData.
|
|
99
|
+
* @param {FormData} [formData] - The form data to return
|
|
100
|
+
* @param {ResponseInit} [init] - Additional response initialization options
|
|
101
|
+
* @returns {Response} A Response object
|
|
102
|
+
* @example
|
|
103
|
+
* const form = new FormData();
|
|
104
|
+
* form.append("key", "value");
|
|
105
|
+
* formData(form);
|
|
106
|
+
*/
|
|
107
|
+
export declare const formData: (formData?: FormData, init?: ResponseInit) => Response;
|
|
108
|
+
/**
|
|
109
|
+
* Creates a Response from URLSearchParams with application/x-www-form-urlencoded content-type.
|
|
110
|
+
* @param {URLSearchParams} [usp] - The URL search parameters to return
|
|
111
|
+
* @param {ResponseInit} [init] - Additional response initialization options
|
|
112
|
+
* @returns {Response} A Response object with application/x-www-form-urlencoded content-type
|
|
113
|
+
* @example
|
|
114
|
+
* const params = new URLSearchParams({ q: "search term" });
|
|
115
|
+
* usp(params);
|
|
116
|
+
*/
|
|
117
|
+
export declare const usp: (usp?: URLSearchParams, init?: ResponseInit) => Response;
|
|
118
|
+
/**
|
|
119
|
+
* Creates a Response from various body types with automatic content-type detection.
|
|
120
|
+
* Supports strings, objects (JSON), Blobs, ArrayBuffers, FormData, URLSearchParams, and ReadableStreams.
|
|
121
|
+
* @param {BodyInit|Record<string, unknown>} [body] - The body content to return
|
|
122
|
+
* @param {ResponseInit} [init] - Additional response initialization options
|
|
123
|
+
* @returns {Response} A Response object with appropriate content-type
|
|
124
|
+
* @example
|
|
125
|
+
* send("text"); // text/plain
|
|
126
|
+
* send({ message: "success" }); // application/json; charset=utf-8
|
|
127
|
+
* send(new Blob([])); // blob.type || application/octet-stream
|
|
128
|
+
* send(new FormData()); // multipart/form-data
|
|
129
|
+
* send(new URLSearchParams()); // application/x-www-form-urlencoded
|
|
130
|
+
*/
|
|
131
|
+
export declare const send: (body?: BodyInit | Record<string, unknown>, init?: ResponseInit) => Response;
|
|
132
|
+
/**
|
|
133
|
+
* Options for setting cookies.
|
|
134
|
+
* @type {Object} CookieOptions
|
|
135
|
+
* @property {string} [path] - The path for which the cookie is valid
|
|
136
|
+
* @property {string} [domain] - The domain for which the cookie is valid
|
|
137
|
+
* @property {Date|number|string} [expires] - Expiration date of the cookie
|
|
138
|
+
* @property {number} [maxAge] - Maximum age of the cookie in seconds
|
|
139
|
+
* @property {boolean} [httpOnly] - If true, the cookie is not accessible via JavaScript
|
|
140
|
+
* @property {boolean} [secure] - If true, the cookie is only sent over HTTPS
|
|
141
|
+
* @property {"Strict"|"Lax"|"None"} [sameSite] - SameSite attribute for the cookie
|
|
142
|
+
*/
|
|
143
|
+
export interface CookieOptions {
|
|
144
|
+
path?: string;
|
|
145
|
+
domain?: string;
|
|
146
|
+
expires?: Date | number | string;
|
|
147
|
+
maxAge?: number;
|
|
148
|
+
httpOnly?: boolean;
|
|
149
|
+
secure?: boolean;
|
|
150
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Tuple representing a cookie header (key-value pair for Set-Cookie header).
|
|
154
|
+
* @type {[string, string]} CookieTuple
|
|
155
|
+
*/
|
|
156
|
+
type CookieTuple = [string, string];
|
|
157
|
+
/**
|
|
158
|
+
* Creates a Set-Cookie header tuple with the given name, value, and options.
|
|
159
|
+
* @param {string} name - The name of the cookie
|
|
160
|
+
* @param {string} value - The value of the cookie
|
|
161
|
+
* @param {CookieOptions} [options] - Cookie configuration options
|
|
162
|
+
* @returns {CookieTuple} A tuple containing the header name "Set-Cookie" and the cookie string
|
|
163
|
+
* @example
|
|
164
|
+
* const cookie = setCookie("session", "abc123", { httpOnly: true, secure: true });
|
|
165
|
+
* // Returns: ["Set-Cookie", "session=abc123; HttpOnly; Secure"]
|
|
166
|
+
*/
|
|
167
|
+
export declare const setCookie: (name: string, value: string, options?: CookieOptions) => CookieTuple;
|
|
168
|
+
/**
|
|
169
|
+
* Creates a Set-Cookie header tuple to clear/remove a cookie.
|
|
170
|
+
* Sets the cookie with an empty value and an expired date.
|
|
171
|
+
* @param {string} name - The name of the cookie to clear
|
|
172
|
+
* @param {CookieOptions} [options] - Cookie configuration options (path/domain must match original cookie)
|
|
173
|
+
* @returns {CookieTuple} A tuple containing the header name "Set-Cookie" and the cookie clearing string
|
|
174
|
+
* @example
|
|
175
|
+
* const cookie = clearCookie("session", { path: "/" });
|
|
176
|
+
* // Returns: ["Set-Cookie", "session=; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/"]
|
|
177
|
+
*/
|
|
178
|
+
export declare const clearCookie: (name: string, options?: CookieOptions) => CookieTuple;
|
|
179
|
+
export {};
|
|
180
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,KAAK,EAAW,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM,GACjB,QAAQ,MAAM,EACd,UAAU,MAAM,GAAG,IAAI,EACvB,OAAO,YAAY,KAClB,QAYF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,GAAI,UAAU,MAAM,EAAE,OAAO,YAAY,KAAG,QAWhE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO,GAClB,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAA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