Skip to content
This repository has been archived by the owner on Feb 19, 2025. It is now read-only.

Commit

Permalink
Merge pull request #40 from magne4000/main
Browse files Browse the repository at this point in the history
fix: Cannot assign to read only property 'clone'
  • Loading branch information
sinclairnick authored Aug 26, 2024
2 parents d3cffb1 + d066ae2 commit 3eb5965
Show file tree
Hide file tree
Showing 11 changed files with 1,669 additions and 1,363 deletions.
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"private": false,
"repository": "https://github.com/sinclairnick/webroute",
"scripts": {
"build": "tsup-node",
"build": "tsup",
"check": "tsc --noEmit",
"publish-pkg": "pnpm run build && pnpm publish --access=public --no-git-checks",
"test": "vitest",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"private": false,
"repository": "https://github.com/sinclairnick/webroute",
"scripts": {
"build": "tsup-node",
"build": "tsup",
"publish-pkg": "pnpm run build && pnpm publish --access=public --no-git-checks"
},
"types": "dist/index.d.ts"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"main": "dist/index.mjs",
"repository": "https://github.com/sinclairnick/webroute",
"scripts": {
"build": "tsup-node",
"build": "tsup",
"publish-pkg": "pnpm run build && pnpm publish --access=public --no-git-checks",
"start": "node ./dist/index.mjs"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"private": false,
"repository": "https://github.com/sinclairnick/webroute",
"scripts": {
"build": "tsup-node",
"build": "tsup",
"check": "tsc --noEmit",
"publish-pkg": "pnpm run build && pnpm publish --access=public --no-git-checks",
"test": "vitest",
Expand Down
2 changes: 1 addition & 1 deletion packages/oas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"module": "dist/index.mjs",
"repository": "https://github.com/sinclairnick/webroute",
"scripts": {
"build": "tsup-node",
"build": "tsup",
"check": "tsc --noEmit",
"publish-pkg": "pnpm run build && pnpm publish --access=public --no-git-checks",
"test": "vitest",
Expand Down
2 changes: 1 addition & 1 deletion packages/route/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"private": false,
"repository": "https://github.com/sinclairnick/webroute",
"scripts": {
"build": "tsup-node",
"build": "tsup",
"check": "tsc --noEmit",
"publish-pkg": "pnpm run build && pnpm publish --access=public --no-git-checks",
"test": "vitest",
Expand Down
9 changes: 6 additions & 3 deletions packages/route/src/route/handler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AnyRouteBuilder, RouteBuilder } from "./builder";
import { Def, createParseFn } from "./util";
import { getParseFn } from "@webroute/schema";
import { fixRequestClone, fixResponseClone } from "../patch";
import { isBun } from "../../util";

function createNewBuilder(
configA: AnyHandlerDefinition,
Expand Down Expand Up @@ -109,7 +110,7 @@ export function createBuilder<TPath extends string | undefined = undefined>(
},
handle(handler) {
const _handler = async (_req: Request) => {
const req = fixRequestClone(_req);
const req = isBun ? fixRequestClone(_req) : _req;

const parse = createParseFn(req, def);
const middlewareOut: MiddlewareOutFn[] = [];
Expand Down Expand Up @@ -175,7 +176,9 @@ export function createBuilder<TPath extends string | undefined = undefined>(
}
}

response = fixResponseClone(response);
if (isBun) {
response = fixResponseClone(response);
}

// --- RES MIDDLEWARE ---
// Run through outgoing middleware
Expand All @@ -187,7 +190,7 @@ export function createBuilder<TPath extends string | undefined = undefined>(

// Set response if one was returned
if (result) {
response = fixResponseClone(result);
response = isBun ? fixResponseClone(result) : result;
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/route/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ export const cached = <T extends () => any>(fn: T) => {
called = true;
return result;
};
};
};

// @ts-ignore
export const isBun = typeof Bun !== "undefined";
2 changes: 1 addition & 1 deletion packages/router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"module": "dist/index.mjs",
"repository": "https://github.com/sinclairnick/webroute",
"scripts": {
"build": "tsup-node",
"build": "tsup",
"publish-pkg": "pnpm run build && pnpm publish --access=public --no-git-checks",
"test": "vitest",
"docs": "typedoc"
Expand Down
6 changes: 3 additions & 3 deletions packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"superjson": "^2.2.1",
"superstruct": "^1.0.4",
"tsup": "^8.0.1",
"valibot": "0.31.0-rc.0",
"valibot": "^0.37.0",
"vitest": "^1.6.0",
"yup": "^1.4.0",
"zod": "^3.22.4"
Expand Down Expand Up @@ -87,13 +87,13 @@
"joi": "^17.13.1",
"runtypes": "^6.7.0",
"superstruct": "^1.0.4",
"valibot": "0.31.0-rc.0",
"valibot": "^0.37.0",
"yup": "^1.4.0",
"zod": "^3.22.4"
},
"repository": "https://github.com/sinclairnick/webroute",
"scripts": {
"build": "tsup-node",
"build": "tsup",
"publish-pkg": "pnpm run build && pnpm publish --access=public --no-git-checks",
"test": "vitest",
"docs": "typedoc"
Expand Down
Loading

0 comments on commit 3eb5965

Please sign in to comment.