@cudenix/cudenix 0.0.28 → 0.0.29
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/addon.d.ts +5 -0
- package/dist/addon.d.ts.map +1 -0
- package/dist/addon.js +2 -0
- package/dist/addon.js.map +1 -0
- package/dist/app.d.ts +7 -8
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +30 -175
- package/dist/app.js.map +1 -1
- package/dist/compile.d.ts +4 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +154 -0
- package/dist/compile.js.map +1 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +7 -4
- package/dist/context.js.map +1 -1
- package/dist/ecosystem/client/client.d.ts.map +1 -1
- package/dist/ecosystem/client/client.js +12 -0
- package/dist/ecosystem/client/client.js.map +1 -1
- package/dist/ecosystem/compress/compress.d.ts +13 -0
- package/dist/ecosystem/compress/compress.d.ts.map +1 -0
- package/dist/ecosystem/compress/compress.js +87 -0
- package/dist/ecosystem/compress/compress.js.map +1 -0
- package/dist/ecosystem/compress/compression-stream.d.ts +14 -0
- package/dist/ecosystem/compress/compression-stream.d.ts.map +1 -0
- package/dist/ecosystem/compress/compression-stream.js +20 -0
- package/dist/ecosystem/compress/compression-stream.js.map +1 -0
- package/dist/ecosystem/compress/index.d.ts +2 -0
- package/dist/ecosystem/compress/index.d.ts.map +1 -0
- package/dist/ecosystem/compress/index.js +2 -0
- package/dist/ecosystem/compress/index.js.map +1 -0
- package/dist/ecosystem/cors/cors.d.ts +1 -1
- package/dist/ecosystem/cors/cors.d.ts.map +1 -1
- package/dist/ecosystem/cors/cors.js +18 -17
- package/dist/ecosystem/cors/cors.js.map +1 -1
- package/dist/ecosystem/i18n/i18n.d.ts +1 -1
- package/dist/ecosystem/i18n/i18n.d.ts.map +1 -1
- package/dist/ecosystem/i18n/i18n.js +100 -88
- package/dist/ecosystem/i18n/i18n.js.map +1 -1
- package/dist/ecosystem/openapi/openapi.d.ts.map +1 -1
- package/dist/ecosystem/openapi/openapi.js +133 -111
- package/dist/ecosystem/openapi/openapi.js.map +1 -1
- package/dist/ecosystem/trycatch/trycatch.d.ts.map +1 -1
- package/dist/ecosystem/trycatch/trycatch.js +11 -12
- package/dist/ecosystem/trycatch/trycatch.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/response.d.ts +3 -0
- package/dist/response.d.ts.map +1 -0
- package/dist/response.js +35 -0
- package/dist/response.js.map +1 -0
- package/dist/utils/get-cookies.d.ts.map +1 -1
- package/dist/utils/get-cookies.js +5 -2
- package/dist/utils/get-cookies.js.map +1 -1
- package/dist/utils/merge.d.ts.map +1 -1
- package/dist/utils/merge.js +5 -1
- package/dist/utils/merge.js.map +1 -1
- package/package.json +24 -20
|
@@ -1,116 +1,128 @@
|
|
|
1
1
|
import { readdir } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { module
|
|
3
|
+
import { module } from "../../module.js";
|
|
4
4
|
import { getRequestContext } from "../../storage.js";
|
|
5
5
|
import { Empty } from "../../utils/empty.js";
|
|
6
6
|
import { getCookies } from "../../utils/get-cookies.js";
|
|
7
7
|
const loadTranslations = async (directory) => {
|
|
8
|
-
const result =
|
|
8
|
+
const result = new Empty();
|
|
9
9
|
const entries = await readdir(directory, {
|
|
10
10
|
withFileTypes: true,
|
|
11
11
|
});
|
|
12
|
-
for (
|
|
12
|
+
for (let i = 0; i < entries.length; i++) {
|
|
13
|
+
const entry = entries[i];
|
|
14
|
+
if (!entry) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
13
17
|
const fullPath = join(directory, entry.name);
|
|
14
18
|
if (entry.isDirectory()) {
|
|
15
19
|
result[entry.name] = await loadTranslations(fullPath);
|
|
20
|
+
continue;
|
|
16
21
|
}
|
|
17
|
-
|
|
22
|
+
if (entry.isFile() && entry.name.endsWith(".json")) {
|
|
18
23
|
const data = await Bun.file(fullPath).json();
|
|
19
24
|
if (entry.name === "index.json") {
|
|
20
25
|
Object.assign(result, data);
|
|
26
|
+
continue;
|
|
21
27
|
}
|
|
22
|
-
|
|
23
|
-
const key = entry.name.slice(0, -5);
|
|
24
|
-
result[key] = data;
|
|
25
|
-
}
|
|
28
|
+
result[entry.name.slice(0, -5)] = data;
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
return result;
|
|
29
32
|
};
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const i18n = memory.get("i18n");
|
|
61
|
-
if (!i18n) {
|
|
62
|
-
return next();
|
|
63
|
-
}
|
|
64
|
-
const language = getCookies(headers)[i18n.cookie ?? "Accept-Language"] ??
|
|
65
|
-
headers.get(i18n.header ?? "Accept-Language");
|
|
66
|
-
store.i18n = {
|
|
67
|
-
language: i18n.languages.includes(language)
|
|
68
|
-
? language
|
|
69
|
-
: i18n.language,
|
|
33
|
+
export const i18n = {
|
|
34
|
+
addon: (path, language, options) => {
|
|
35
|
+
return async function () {
|
|
36
|
+
const directories = await readdir(path, {
|
|
37
|
+
withFileTypes: true,
|
|
38
|
+
});
|
|
39
|
+
const languages = directories
|
|
40
|
+
.filter((directory) => {
|
|
41
|
+
return directory.isDirectory();
|
|
42
|
+
})
|
|
43
|
+
.map((directory) => {
|
|
44
|
+
return directory.name;
|
|
45
|
+
});
|
|
46
|
+
this.memory.set("i18n", {
|
|
47
|
+
...options,
|
|
48
|
+
language,
|
|
49
|
+
languages,
|
|
50
|
+
path,
|
|
51
|
+
translations: new Empty(),
|
|
52
|
+
});
|
|
53
|
+
const i18n = this.memory.get("i18n");
|
|
54
|
+
for (let i = 0; i < languages.length; i++) {
|
|
55
|
+
const language = languages[i];
|
|
56
|
+
if (!language) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
i18n.translations[language] = await loadTranslations(join(path, language));
|
|
60
|
+
}
|
|
61
|
+
await Bun.write(join(path, "types.d.ts"), `namespace Cudenix.i18n { interface Translations ${JSON.stringify(i18n.translations[language])}; };`);
|
|
62
|
+
return "i18n";
|
|
70
63
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
for (let i = 0; i < split.length; i++) {
|
|
96
|
-
translation = translation[split[i]];
|
|
97
|
-
}
|
|
98
|
-
if (options?.replace) {
|
|
99
|
-
const keys = Object.keys(options.replace);
|
|
64
|
+
},
|
|
65
|
+
get language() {
|
|
66
|
+
return getRequestContext()?.store.i18n?.language;
|
|
67
|
+
},
|
|
68
|
+
module: () => {
|
|
69
|
+
return module().middleware(({ memory, request: { raw }, store }, next) => {
|
|
70
|
+
const i18n = memory.get("i18n");
|
|
71
|
+
if (!i18n) {
|
|
72
|
+
return next();
|
|
73
|
+
}
|
|
74
|
+
const language = getCookies(raw.headers)[i18n.cookie ?? "Accept-Language"] ??
|
|
75
|
+
raw.headers.get(i18n.header ?? "Accept-Language") ??
|
|
76
|
+
i18n.language;
|
|
77
|
+
store.i18n = {
|
|
78
|
+
language: i18n.languages.indexOf(language) !== -1
|
|
79
|
+
? language
|
|
80
|
+
: i18n.language,
|
|
81
|
+
};
|
|
82
|
+
return next();
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
replace: (translation, replace) => {
|
|
86
|
+
const keys = Object.keys(replace);
|
|
87
|
+
let replaced = translation;
|
|
100
88
|
for (let i = 0; i < keys.length; i++) {
|
|
101
89
|
const key = keys[i];
|
|
102
|
-
|
|
90
|
+
if (!key) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
replaced = replaced.replaceAll(`\${${key}}`, replace[key] ?? "");
|
|
103
94
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
95
|
+
return replaced;
|
|
96
|
+
},
|
|
97
|
+
translate: (path, { language, replace, } = new Empty()) => {
|
|
98
|
+
const context = getRequestContext();
|
|
99
|
+
const translations = context?.memory.get("i18n")
|
|
100
|
+
?.translations[language ??
|
|
101
|
+
(context?.store).i18n
|
|
102
|
+
.language];
|
|
103
|
+
if (!translations) {
|
|
104
|
+
return path;
|
|
105
|
+
}
|
|
106
|
+
const split = path.split(".");
|
|
107
|
+
let translation = translations;
|
|
108
|
+
for (let i = 0; i < split.length; i++) {
|
|
109
|
+
const key = split[i];
|
|
110
|
+
if (!key) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
translation = translation[key] ?? "";
|
|
114
|
+
}
|
|
115
|
+
if (replace) {
|
|
116
|
+
const keys = Object.keys(replace);
|
|
117
|
+
for (let i = 0; i < keys.length; i++) {
|
|
118
|
+
const key = keys[i];
|
|
119
|
+
if (!key) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
translation = translation.replaceAll(`\${${key}}`, replace[key] ?? "");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return translation;
|
|
111
126
|
},
|
|
112
|
-
module,
|
|
113
|
-
replace,
|
|
114
|
-
translate,
|
|
115
127
|
};
|
|
116
128
|
//# sourceMappingURL=i18n.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../../src/ecosystem/i18n/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../../src/ecosystem/i18n/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAoDjD,MAAM,gBAAgB,GAAG,KAAK,EAAE,SAAiB,EAAE,EAAE;IACpD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAiB,CAAC;IAE1C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,SAAS,EAAE;QACxC,aAAa,EAAE,IAAI;KACnB,CAAC,CAAC;IAEH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAEzB,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,SAAS;QACV,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAE7C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE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AAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,aAAa;IACtB,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../../src/ecosystem/openapi/openapi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAW,MAAM,SAAS,CAAC;AAI5C,KAAK,iBAAiB,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElE,UAAU,YAAY;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,aAAa;IACtB,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;CACpB;AAaD,eAAO,MAAM,OAAO;0BAEJ,iBAAiB,qCAK5B,YAAY,MAEE,MAAM,GAAG;uBAgOR,aAAa;;;;;;;;;;;;;;;;;;;;;;;;CAuBhC,CAAC"}
|
|
@@ -1,137 +1,159 @@
|
|
|
1
1
|
import { scalar } from "../../ecosystem/openapi/scalar.js";
|
|
2
2
|
import { success } from "../../index.js";
|
|
3
|
-
import { module
|
|
3
|
+
import { module } from "../../module.js";
|
|
4
4
|
import { Empty } from "../../utils/empty.js";
|
|
5
5
|
const endsWithQuestionMarkRegexp = /\?$/;
|
|
6
6
|
const endsWithSRegexp = /s$/;
|
|
7
7
|
const startsWithEllipsisRegexp = /^\.{3}/;
|
|
8
8
|
const startsWithSlashRegexp = /^\/{/;
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
const contentTypes = [
|
|
10
|
+
"application/json",
|
|
11
|
+
"multipart/form-data",
|
|
12
|
+
"text/plain",
|
|
13
|
+
];
|
|
14
|
+
export const openapi = {
|
|
15
|
+
addon: (toJsonSchema, { description = "Cudenix Documentation", title = "Cudenix Documentation", version = "0.0.1", } = new Empty()) => {
|
|
16
|
+
return function () {
|
|
17
|
+
const paths = new Empty();
|
|
18
|
+
const methods = Array.from(this.endpoints.keys());
|
|
19
|
+
const tags = new Set();
|
|
20
|
+
for (let i = 0; i < methods.length; i++) {
|
|
21
|
+
const method = methods[i];
|
|
22
|
+
if (!method) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const endpoints = this.endpoints.get(method);
|
|
26
|
+
if (!endpoints) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
for (let j = 0; j < endpoints.length; j++) {
|
|
30
|
+
const endpoint = endpoints[j];
|
|
31
|
+
if (!endpoint) {
|
|
25
32
|
continue;
|
|
26
33
|
}
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
const path = endpoint.path
|
|
35
|
+
.replaceAll(/:(\w+)/g, "{$1}")
|
|
36
|
+
.replaceAll(/\.{3}(\w+)/g, "{$1}");
|
|
37
|
+
const operation = new Empty();
|
|
38
|
+
for (let k = 0; k < endpoint.chain.length; k++) {
|
|
39
|
+
const link = endpoint.chain[k];
|
|
40
|
+
if (link?.type !== "VALIDATOR") {
|
|
31
41
|
continue;
|
|
32
42
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const keys = Object.keys(link.request);
|
|
44
|
+
for (let l = 0; l < keys.length; l++) {
|
|
45
|
+
const key = keys[l];
|
|
46
|
+
if (!key) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (key !== "body") {
|
|
50
|
+
const _in = key.replace(endsWithSRegexp, "");
|
|
51
|
+
const schema = toJsonSchema(link.request[key]);
|
|
52
|
+
operation.parameters ??= [];
|
|
53
|
+
if (schema.type === "object") {
|
|
54
|
+
const keys = Object.keys(schema.properties);
|
|
55
|
+
for (let m = 0; m < keys.length; m++) {
|
|
56
|
+
const key = keys[m];
|
|
57
|
+
if (!key) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const property = schema.properties[key];
|
|
61
|
+
operation.parameters.push({
|
|
62
|
+
in: _in,
|
|
63
|
+
name: key,
|
|
64
|
+
required: schema.required?.includes(key) ?? false,
|
|
65
|
+
schema: property,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
continue;
|
|
47
69
|
}
|
|
70
|
+
operation.parameters.push({
|
|
71
|
+
in: _in,
|
|
72
|
+
schema,
|
|
73
|
+
});
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
operation.requestBody ??= {
|
|
77
|
+
content: new Empty(),
|
|
78
|
+
};
|
|
79
|
+
for (let m = 0; m < contentTypes.length; m++) {
|
|
80
|
+
const contentType = contentTypes[m];
|
|
81
|
+
if (!contentType) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
operation.requestBody.content[contentType] = {
|
|
85
|
+
schema: toJsonSchema(link.request[key]),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const params = endpoint.path.match(/(?::|\.{3})(\w+)\??/g);
|
|
91
|
+
if (params) {
|
|
92
|
+
for (let k = 0; k < params.length; k++) {
|
|
93
|
+
const param = params[k];
|
|
94
|
+
if (!param) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const name = param
|
|
98
|
+
.replaceAll(/^[:.]*/g, "")
|
|
99
|
+
.replace("?", "");
|
|
100
|
+
if (operation.parameters?.some((parameter) => {
|
|
101
|
+
return (parameter.in === "path" &&
|
|
102
|
+
parameter.name === name);
|
|
103
|
+
})) {
|
|
48
104
|
continue;
|
|
49
105
|
}
|
|
106
|
+
operation.parameters ??= [];
|
|
50
107
|
operation.parameters.push({
|
|
51
|
-
in:
|
|
52
|
-
|
|
108
|
+
in: "path",
|
|
109
|
+
name,
|
|
110
|
+
required: !endsWithQuestionMarkRegexp.test(param),
|
|
111
|
+
schema: {
|
|
112
|
+
pattern: startsWithEllipsisRegexp.test(param)
|
|
113
|
+
? ".*"
|
|
114
|
+
: undefined,
|
|
115
|
+
type: "string",
|
|
116
|
+
},
|
|
53
117
|
});
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
operation.requestBody ??= {
|
|
57
|
-
content: new Empty(),
|
|
58
|
-
};
|
|
59
|
-
const contentType = [
|
|
60
|
-
"application/json",
|
|
61
|
-
"multipart/form-data",
|
|
62
|
-
"text/plain",
|
|
63
|
-
];
|
|
64
|
-
for (let m = 0; m < contentType.length; m++) {
|
|
65
|
-
operation.requestBody.content[contentType[m]] = {
|
|
66
|
-
schema: toJsonSchema(link.request[key]),
|
|
67
|
-
};
|
|
68
118
|
}
|
|
69
119
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
for (let k = 0; k < params.length; k++) {
|
|
74
|
-
const param = params[k];
|
|
75
|
-
const name = param
|
|
76
|
-
.replaceAll(/^[:.]*/g, "")
|
|
77
|
-
.replace("?", "");
|
|
78
|
-
if (operation.parameters?.some((parameter) => {
|
|
79
|
-
return (parameter.in === "path" &&
|
|
80
|
-
parameter.name === name);
|
|
81
|
-
})) {
|
|
120
|
+
if (!startsWithSlashRegexp.test(path)) {
|
|
121
|
+
const tag = path.split("/")[1];
|
|
122
|
+
if (!tag) {
|
|
82
123
|
continue;
|
|
83
124
|
}
|
|
84
|
-
operation.
|
|
85
|
-
|
|
86
|
-
in: "path",
|
|
87
|
-
name,
|
|
88
|
-
required: !endsWithQuestionMarkRegexp.test(param),
|
|
89
|
-
schema: {
|
|
90
|
-
pattern: startsWithEllipsisRegexp.test(param)
|
|
91
|
-
? ".*"
|
|
92
|
-
: undefined,
|
|
93
|
-
type: "string",
|
|
94
|
-
},
|
|
95
|
-
});
|
|
125
|
+
operation.tags = [tag];
|
|
126
|
+
tags.add(tag);
|
|
96
127
|
}
|
|
128
|
+
paths[path] ??= new Empty();
|
|
129
|
+
paths[path][method.toLowerCase()] = operation;
|
|
97
130
|
}
|
|
98
|
-
if (!startsWithSlashRegexp.test(path)) {
|
|
99
|
-
const tag = path.split("/")[1];
|
|
100
|
-
operation.tags = [tag];
|
|
101
|
-
tags.add(tag);
|
|
102
|
-
}
|
|
103
|
-
paths[path] ??= {};
|
|
104
|
-
paths[path][methods[i].toLowerCase()] = operation;
|
|
105
131
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
})
|
|
132
|
+
this.memory.set("openapi", {
|
|
133
|
+
info: {
|
|
134
|
+
description,
|
|
135
|
+
title,
|
|
136
|
+
version,
|
|
137
|
+
},
|
|
138
|
+
openapi: "3.1.0",
|
|
139
|
+
paths,
|
|
140
|
+
tags: Array.from(tags).map((tag) => ({
|
|
141
|
+
name: tag,
|
|
142
|
+
})),
|
|
143
|
+
});
|
|
144
|
+
return "openapi";
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
module: (options) => {
|
|
148
|
+
const url = `${options?.path ?? "/openapi"}`;
|
|
149
|
+
return module()
|
|
150
|
+
.route("GET", url, ({ memory, response: { headers } }) => {
|
|
151
|
+
headers.set("Content-Type", "text/html");
|
|
152
|
+
return success(scalar("Cudenix Documentation", JSON.stringify(memory.get("openapi")), JSON.stringify({})), 200, false);
|
|
153
|
+
})
|
|
154
|
+
.route("GET", `${url}/json`, ({ memory }) => {
|
|
155
|
+
return success(memory.get("openapi"));
|
|
118
156
|
});
|
|
119
|
-
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
const module = (options) => {
|
|
123
|
-
const url = `${options?.path ?? "/openapi"}`;
|
|
124
|
-
return _module()
|
|
125
|
-
.route("GET", url, ({ memory, response: { headers } }) => {
|
|
126
|
-
headers.set("content-type", "text/html");
|
|
127
|
-
return success(scalar("Cudenix Documentation", JSON.stringify(memory.get("openapi")), JSON.stringify({})), 200, false);
|
|
128
|
-
})
|
|
129
|
-
.route("GET", `${url}/json`, ({ memory }) => {
|
|
130
|
-
return success(memory.get("openapi"));
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
export const openapi = {
|
|
134
|
-
addon,
|
|
135
|
-
module,
|
|
157
|
+
},
|
|
136
158
|
};
|
|
137
159
|
//# sourceMappingURL=openapi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi.js","sourceRoot":"","sources":["../../../src/ecosystem/openapi/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAY,OAAO,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"openapi.js","sourceRoot":"","sources":["../../../src/ecosystem/openapi/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAY,OAAO,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AActC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AACzC,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,wBAAwB,GAAG,QAAQ,CAAC;AAC1C,MAAM,qBAAqB,GAAG,MAAM,C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"
|
|
1
|
+
{"version":3,"file":"trycatch.d.ts","sourceRoot":"","sources":["../../../src/ecosystem/trycatch/trycatch.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ;;;;;CAUpB,CAAC"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { error } from "../../error.js";
|
|
2
|
-
import { module
|
|
3
|
-
const module = () => {
|
|
4
|
-
return _module().middleware(async (_context, next) => {
|
|
5
|
-
try {
|
|
6
|
-
return await next();
|
|
7
|
-
}
|
|
8
|
-
catch (exception) {
|
|
9
|
-
return error(exception || "An unknown error has occurred", 500);
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
};
|
|
2
|
+
import { module } from "../../module.js";
|
|
13
3
|
export const trycatch = {
|
|
14
|
-
module
|
|
4
|
+
module: () => {
|
|
5
|
+
return module().middleware(async (_context, next) => {
|
|
6
|
+
try {
|
|
7
|
+
return await next();
|
|
8
|
+
}
|
|
9
|
+
catch (exception) {
|
|
10
|
+
return error(exception || "An unknown error has occurred", 500);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
},
|
|
15
14
|
};
|
|
16
15
|
//# sourceMappingURL=trycatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trycatch.js","sourceRoot":"","sources":["../../../src/ecosystem/trycatch/trycatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"trycatch.js","sourceRoot":"","sources":["../../../src/ecosystem/trycatch/trycatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACvB,MAAM,EAAE,GAAG,EAAE;QACZ,OAAO,MAAM,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;YACnD,IAAI,CAAC;gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC;YACrB,CAAC;YAAC,OAAO,SAAS,EAAE,CAAC;gBACpB,OAAO,KAAK,CAAC,SAAS,IAAI,+BAA+B,EAAE,GAAG,CAAC,CAAC;YACjE,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;CACD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
export * from "./addon.js";
|
|
1
2
|
export * from "./app.js";
|
|
3
|
+
export * from "./compile.js";
|
|
2
4
|
export * from "./context.js";
|
|
3
5
|
export * from "./error.js";
|
|
4
6
|
export * from "./global.js";
|
|
5
7
|
export * from "./group.js";
|
|
6
8
|
export * from "./middleware.js";
|
|
7
9
|
export * from "./module.js";
|
|
10
|
+
export * from "./response.js";
|
|
8
11
|
export * from "./route.js";
|
|
9
12
|
export * from "./storage.js";
|
|
10
13
|
export * from "./store.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,mBAAmB,SAAS,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,mBAAmB,SAAS,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
export * from "./addon.js";
|
|
1
2
|
export * from "./app.js";
|
|
3
|
+
export * from "./compile.js";
|
|
2
4
|
export * from "./context.js";
|
|
3
5
|
export * from "./error.js";
|
|
4
6
|
export * from "./global.js";
|
|
5
7
|
export * from "./group.js";
|
|
6
8
|
export * from "./middleware.js";
|
|
7
9
|
export * from "./module.js";
|
|
10
|
+
export * from "./response.js";
|
|
8
11
|
export * from "./route.js";
|
|
9
12
|
export * from "./storage.js";
|
|
10
13
|
export * from "./store.js";
|