Skip to content

Commit e868f7d

Browse files
authored
feat: upgrade Bun v1.2 (#609)
Co-authored-by: danadajian <[email protected]>
1 parent c78940b commit e868f7d

File tree

25 files changed

+4443
-177
lines changed

25 files changed

+4443
-177
lines changed

.github/workflows/github-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: bun install
3535

3636
- name: Build Docs
37-
run: bun nx build docs
37+
run: bunx nx build docs
3838

3939
- name: Setup Pages
4040
uses: actions/configure-pages@v5

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
run: bun tsc
4343

4444
- name: Build and Test
45-
run: bun nx affected --target=build,test
45+
run: bunx nx affected --target=build,test
4646

4747
- name: Check for any generated code that should be committed
4848
run: |

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,3 @@ app/frontend/cypress/screenshots
3232
app/frontend/cypress/videos
3333

3434
.nx/
35-
36-
app/public/*
37-
!app/public/island.svg

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://registry.npmjs.org/

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM oven/bun:1.1.42
1+
FROM oven/bun:1.2.0
22
WORKDIR /app
33

44
RUN useradd -ms /bin/sh admin

action/dist/main.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ var require_proxy = __commonJS({
236236
})();
237237
if (proxyVar) {
238238
try {
239-
return new URL(proxyVar);
239+
return new DecodedURL(proxyVar);
240240
} catch (_a) {
241241
if (!proxyVar.startsWith("http://") && !proxyVar.startsWith("https://"))
242-
return new URL(`http://${proxyVar}`);
242+
return new DecodedURL(`http://${proxyVar}`);
243243
}
244244
} else {
245245
return void 0;
@@ -282,6 +282,19 @@ var require_proxy = __commonJS({
282282
const hostLower = host.toLowerCase();
283283
return hostLower === "localhost" || hostLower.startsWith("127.") || hostLower.startsWith("[::1]") || hostLower.startsWith("[0:0:0:0:0:0:0:1]");
284284
}
285+
var DecodedURL = class extends URL {
286+
constructor(url, base) {
287+
super(url, base);
288+
this._decodedUsername = decodeURIComponent(super.username);
289+
this._decodedPassword = decodeURIComponent(super.password);
290+
}
291+
get username() {
292+
return this._decodedUsername;
293+
}
294+
get password() {
295+
return this._decodedPassword;
296+
}
297+
};
285298
}
286299
});
287300

@@ -5267,6 +5280,13 @@ var require_body = __commonJS({
52675280
var { isUint8Array, isArrayBuffer } = require("util/types");
52685281
var { File: UndiciFile } = require_file();
52695282
var { parseMIMEType, serializeAMimeType } = require_dataURL();
5283+
var random;
5284+
try {
5285+
const crypto = require("crypto");
5286+
random = (max) => crypto.randomInt(0, max);
5287+
} catch {
5288+
random = (max) => Math.floor(Math.random(max));
5289+
}
52705290
var ReadableStream = globalThis.ReadableStream;
52715291
var File = NativeFile ?? UndiciFile;
52725292
var textEncoder = new TextEncoder();
@@ -5309,7 +5329,7 @@ var require_body = __commonJS({
53095329
} else if (ArrayBuffer.isView(object)) {
53105330
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength));
53115331
} else if (util.isFormDataLike(object)) {
5312-
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, "0")}`;
5332+
const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, "0")}`;
53135333
const prefix = `--${boundary}\r
53145334
Content-Disposition: form-data`;
53155335
const escape2 = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
@@ -17825,7 +17845,7 @@ var require_lib = __commonJS({
1782517845
}
1782617846
const usingSsl = parsedUrl.protocol === "https:";
1782717847
proxyAgent = new undici_1.ProxyAgent(Object.assign({ uri: proxyUrl.href, pipelining: !this._keepAlive ? 0 : 1 }, (proxyUrl.username || proxyUrl.password) && {
17828-
token: `${proxyUrl.username}:${proxyUrl.password}`
17848+
token: `Basic ${Buffer.from(`${proxyUrl.username}:${proxyUrl.password}`).toString("base64")}`
1782917849
}));
1783017850
this._proxyAgentDispatcher = proxyAgent;
1783117851
if (usingSsl && this._ignoreSslError) {
@@ -31520,7 +31540,7 @@ var LRUCache = class _LRUCache {
3152031540
}
3152131541
/**
3152231542
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
31523-
* passed to {@link LRLUCache#load}.
31543+
* passed to {@link LRUCache#load}.
3152431544
*
3152531545
* The `start` fields are calculated relative to a portable `Date.now()`
3152631546
* timestamp, even if `performance.now()` is available.

action/dist/main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/app.tsx

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { PropsWithChildren } from 'react';
1+
import React from 'react';
22
import { MainPage } from './frontend/components/main-page';
33
import { ClientProvider } from './frontend/providers/client-provider';
44
import { BaseImageStateProvider } from './frontend/providers/base-image-state-provider';
@@ -31,22 +31,3 @@ export function App(props: {
3131
</ClientProvider>
3232
);
3333
}
34-
35-
export function OuterHtml(props: PropsWithChildren) {
36-
return (
37-
<html lang="en">
38-
<head>
39-
<meta charSet="UTF-8" />
40-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
41-
<link rel="icon" type="image/svg+xml" href="/public/island.svg" />
42-
<link
43-
rel="stylesheet"
44-
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
45-
/>
46-
<link rel="stylesheet" href="/public/globals.css" />
47-
<title>Comparadise</title>
48-
</head>
49-
<body>{props.children}</body>
50-
</html>
51-
);
52-
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { S3Client } from './s3Client';
2-
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
3-
import { GetObjectCommand } from '@aws-sdk/client-s3';
1+
import { s3 } from 'bun';
42

5-
export const getTemporaryObjectUrl = async (key: string, bucket: string) => {
6-
const command = new GetObjectCommand({ Bucket: bucket, Key: key });
7-
return getSignedUrl(S3Client, command, { expiresIn: oneHour });
3+
export const getTemporaryObjectUrl = async (
4+
filePath: string,
5+
bucket: string
6+
) => {
7+
return s3.file(filePath, { bucket }).presign({ expiresIn: oneHour });
88
};
99

1010
const oneHour = 3600;

app/backend/src/router.ts

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
import { AnyTRPCRouter, initTRPC } from '@trpc/server';
2-
import {
3-
type FetchHandlerRequestOptions,
4-
fetchRequestHandler
5-
} from '@trpc/server/adapters/fetch';
1+
import { initTRPC } from '@trpc/server';
62
import {
73
fetchCurrentPageInputSchema,
84
updateBaseImagesInputSchema
95
} from './schema';
106
import { fetchCurrentPage } from './fetchCurrentPage';
117
import { updateBaseImagesInS3 } from './updateBaseImagesInS3';
12-
import Elysia from 'elysia';
138

149
const t = initTRPC.create();
1510

@@ -23,47 +18,3 @@ export const router = t.router({
2318
});
2419

2520
export type AppRouter = typeof router;
26-
27-
type TRPCOptions = {
28-
endpoint?: string;
29-
} & Omit<
30-
FetchHandlerRequestOptions<AnyTRPCRouter>,
31-
'req' | 'router' | 'endpoint'
32-
>;
33-
34-
export const trpcRouter =
35-
(
36-
router: AnyTRPCRouter,
37-
{ endpoint = '/trpc', ...options }: TRPCOptions = { endpoint: '/trpc' }
38-
) =>
39-
(app: Elysia) => {
40-
return app
41-
.onParse(({ request: { url } }) => {
42-
if (getPath(url).startsWith(endpoint)) return true;
43-
})
44-
.get(`${endpoint}/*`, async ({ request }) => {
45-
return fetchRequestHandler({
46-
...options,
47-
req: request,
48-
router,
49-
endpoint
50-
});
51-
})
52-
.post(`${endpoint}/*`, async ({ request }) => {
53-
return fetchRequestHandler({
54-
...options,
55-
req: request,
56-
router,
57-
endpoint
58-
});
59-
});
60-
};
61-
62-
const getPath = (url: string) => {
63-
const start = url.indexOf('/', 9);
64-
const end = url.indexOf('?', start);
65-
66-
if (end === -1) return url.slice(start);
67-
68-
return url.slice(start, end);
69-
};

0 commit comments

Comments
 (0)