two-stroke 5.5.0 → 5.6.1
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/api-types.mjs +3 -3
- package/package.json +1 -1
- package/src/index.ts +26 -6
- package/src/types.ts +2 -1
package/bin/api-types.mjs
CHANGED
|
@@ -14,7 +14,7 @@ const NULL = ts.factory.createLiteralTypeNode(ts.factory.createNull());
|
|
|
14
14
|
|
|
15
15
|
await Promise.all(
|
|
16
16
|
services.map(async (service) => {
|
|
17
|
-
const output = await openapiTS(
|
|
17
|
+
const output = await openapiTS(`${service}/doc`, {
|
|
18
18
|
transform(schemaObject) {
|
|
19
19
|
if ("format" in schemaObject && schemaObject.format === "uuid") {
|
|
20
20
|
return schemaObject.nullable
|
|
@@ -25,7 +25,7 @@ await Promise.all(
|
|
|
25
25
|
});
|
|
26
26
|
const printer = ts.createPrinter({});
|
|
27
27
|
const resultFile = ts.createSourceFile(
|
|
28
|
-
`src/__definitions__/${service}-definitions.ts`,
|
|
28
|
+
`src/__definitions__/${service.replace("https://", "")}-definitions.ts`,
|
|
29
29
|
"",
|
|
30
30
|
ts.ScriptTarget.Latest,
|
|
31
31
|
);
|
|
@@ -35,7 +35,7 @@ await Promise.all(
|
|
|
35
35
|
resultFile,
|
|
36
36
|
);
|
|
37
37
|
fs.writeFileSync(
|
|
38
|
-
`src/__definitions__/${service}-definitions.ts`,
|
|
38
|
+
`src/__definitions__/${service.replace("https://", "")}-definitions.ts`,
|
|
39
39
|
await prettier.format(
|
|
40
40
|
`// Autogenerated by two-stroke
|
|
41
41
|
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -92,12 +92,32 @@ export function twoStroke<T extends Env>(title: string, release: string) {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
if (route.method === "POST" || route.method === "PUT") {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
?
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
let rawBody;
|
|
96
|
+
try {
|
|
97
|
+
rawBody = route.input
|
|
98
|
+
? req.headers.get("Content-Type") ===
|
|
99
|
+
"application/x-www-form-urlencoded"
|
|
100
|
+
? Object.fromEntries(new URLSearchParams(await req.text()))
|
|
101
|
+
: await req.json()
|
|
102
|
+
: undefined;
|
|
103
|
+
} catch (e) {
|
|
104
|
+
console.error({
|
|
105
|
+
message: "Request body is required'",
|
|
106
|
+
error: e instanceof Error ? e.message : "Error",
|
|
107
|
+
});
|
|
108
|
+
return new Response(
|
|
109
|
+
JSON.stringify({
|
|
110
|
+
error: "Request body is required",
|
|
111
|
+
issues: [],
|
|
112
|
+
}),
|
|
113
|
+
{
|
|
114
|
+
status: 400,
|
|
115
|
+
headers: {
|
|
116
|
+
"Access-Control-Allow-Origin": "*",
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
);
|
|
120
|
+
}
|
|
101
121
|
const body = route.input
|
|
102
122
|
? route.input.safeParse(rawBody)
|
|
103
123
|
: {
|
package/src/types.ts
CHANGED