chore: use bigint parse/stringify

chore: move cli generator into this repo
This commit is contained in:
izzy
2025-10-22 17:47:18 +01:00
parent f654e4be7d
commit 0b9ccca95b
5 changed files with 181 additions and 27 deletions
+7 -3
View File
@@ -1,11 +1,14 @@
// This file was auto-generated by @insertish/oapi!
import type { APIRoutes } from "./routes.js";
export type { APIRoutes } from "./routes.js";
export * from "./types.js";
import { defaultBaseURL } from "./baseURL.js";
import { pathResolve, queryParams } from "./params.js";
import { JSONParse, JSONStringify } from 'json-with-bigint';
type Methods = APIRoutes["method"];
type PickRoutes<Method extends Methods> = APIRoutes & { method: Method };
@@ -189,7 +192,7 @@ export class API {
}
const passbody = ["head", "get"].includes(method)
? undefined
: JSON.stringify(body);
: JSONStringify(body);
let fetchpath = `${path}?${query.toString()}`;
if (fetchpath.startsWith("/")) {
@@ -205,13 +208,14 @@ export class API {
body: passbody,
});
const respType = config?.responseType || "json";
const data =
fetchdata.status === 204
? null
: await fetchdata[config?.responseType || "json"]();
: await fetchdata[respType === 'json' ? 'text' : respType]();
if (fetchdata.ok) {
return data;
return respType === 'json' ? JSONParse(data as string) : data as never;
} else {
throw data;
}