@rhythmjs/openapi 0.0.2 → 0.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/dist/body/body.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as schemaMiddleware, t as bodyExtractor } from "../runtime-
|
|
1
|
+
import { a as schemaMiddleware, t as bodyExtractor } from "../runtime-BrscD_hj.js";
|
|
2
2
|
//#region src/body/body.ts
|
|
3
3
|
function apiBody(schema, options = {}) {
|
|
4
4
|
const contentType = options.contentType ?? "application/json";
|
package/dist/cookie/cookie.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as schemaMiddleware, n as collectCookies } from "../runtime-
|
|
1
|
+
import { a as schemaMiddleware, n as collectCookies } from "../runtime-BrscD_hj.js";
|
|
2
2
|
//#region src/cookie/cookie.ts
|
|
3
3
|
function apiCookie(schema, options = {}) {
|
|
4
4
|
return schemaMiddleware("cookie", schema, { parameters: [{
|
package/dist/header/header.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as schemaMiddleware, r as collectHeaders } from "../runtime-
|
|
1
|
+
import { a as schemaMiddleware, r as collectHeaders } from "../runtime-BrscD_hj.js";
|
|
2
2
|
//#region src/header/header.ts
|
|
3
3
|
function apiHeader(schema, options = {}) {
|
|
4
4
|
return schemaMiddleware("header", schema, { parameters: [{
|
package/dist/param/param.js
CHANGED
package/dist/query/query.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as schemaMiddleware, i as collectQuery } from "../runtime-
|
|
1
|
+
import { a as schemaMiddleware, i as collectQuery } from "../runtime-BrscD_hj.js";
|
|
2
2
|
//#region src/query/query.ts
|
|
3
3
|
function apiQuery(schema, options = {}) {
|
|
4
4
|
return schemaMiddleware("query", schema, { parameters: [{
|
|
@@ -46,21 +46,6 @@ function collectCookies(request) {
|
|
|
46
46
|
}
|
|
47
47
|
return out;
|
|
48
48
|
}
|
|
49
|
-
function parseMultipart(body, contentTypeHeader) {
|
|
50
|
-
const boundary = /boundary="?([^";]+)"?/i.exec(contentTypeHeader)?.[1];
|
|
51
|
-
if (!boundary) return void 0;
|
|
52
|
-
const pairs = [];
|
|
53
|
-
for (const part of body.split(`--${boundary}`)) {
|
|
54
|
-
const headerEnd = part.indexOf("\r\n\r\n");
|
|
55
|
-
if (headerEnd === -1) continue;
|
|
56
|
-
const headers = part.slice(0, headerEnd);
|
|
57
|
-
const name = /content-disposition:[^\r\n]*\sname="([^"]*)"/i.exec(headers)?.[1];
|
|
58
|
-
if (name === void 0) continue;
|
|
59
|
-
const value = /\sfilename="([^"]*)"/i.exec(headers)?.[1] ?? part.slice(headerEnd + 4).replace(/\r\n$/, "");
|
|
60
|
-
pairs.push([name, value]);
|
|
61
|
-
}
|
|
62
|
-
return collectMultiValue(pairs);
|
|
63
|
-
}
|
|
64
49
|
function bodyExtractor(contentType) {
|
|
65
50
|
return async (ctx) => {
|
|
66
51
|
if (contentType.includes("json")) try {
|
|
@@ -74,6 +59,17 @@ function bodyExtractor(contentType) {
|
|
|
74
59
|
message: "Malformed JSON in request body"
|
|
75
60
|
};
|
|
76
61
|
}
|
|
62
|
+
if (contentType.includes("form-data")) try {
|
|
63
|
+
return {
|
|
64
|
+
ok: true,
|
|
65
|
+
value: collectMultiValue(await ctx.request.clone().formData())
|
|
66
|
+
};
|
|
67
|
+
} catch {
|
|
68
|
+
return {
|
|
69
|
+
ok: false,
|
|
70
|
+
message: "Malformed form data in request body"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
77
73
|
let text;
|
|
78
74
|
try {
|
|
79
75
|
text = await ctx.request.clone().text();
|
|
@@ -87,16 +83,6 @@ function bodyExtractor(contentType) {
|
|
|
87
83
|
ok: true,
|
|
88
84
|
value: collectMultiValue(new URLSearchParams(text))
|
|
89
85
|
};
|
|
90
|
-
if (contentType.includes("form-data")) {
|
|
91
|
-
const value = parseMultipart(text, ctx.request.headers.get("content-type") ?? contentType);
|
|
92
|
-
return value ? {
|
|
93
|
-
ok: true,
|
|
94
|
-
value
|
|
95
|
-
} : {
|
|
96
|
-
ok: false,
|
|
97
|
-
message: "Malformed form data in request body"
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
86
|
return {
|
|
101
87
|
ok: true,
|
|
102
88
|
value: text
|
package/package.json
CHANGED