Skip to content

Commit

Permalink
v0.1.23 fixes json stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamint08 committed May 22, 2024
1 parent fe5cab4 commit 491f6a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/helpers/json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export async function json(req: Request): Promise<Object>{
// @ts-ignore
const readableStream = await req.body.getReader().read();
const uint8Array = readableStream.value;
const bodyString = new TextDecoder().decode(uint8Array);
let body: any = {};
bodyString.split("&").forEach((pair) => {
const [key, value] = pair.split("=");
body[key] = value;
});
return body;
}
2 changes: 2 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { param } from "../helpers/param.ts";
import { version } from "../../package.json";
import MongoService from "../instances/mongodb.ts";
import PgService from "../instances/postgres.ts";
import {json} from "../helpers/json.ts";

let globalFolder = "";

Expand Down Expand Up @@ -347,4 +348,5 @@ export {
MongoService,
PgService,
SendFile,
json
};

0 comments on commit 491f6a1

Please sign in to comment.