mirror of
https://github.com/stoatchat/javascript-client-api.git
synced 2026-07-19 17:13:35 -04:00
chore: use bigint parse/stringify
chore: move cli generator into this repo
This commit is contained in:
+7
-3
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user