-
Notifications
You must be signed in to change notification settings - Fork 32
fix: return content-type headers on non-bun runtimes #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
4dc837e
fix: return ElysiaFile instead of Response to get content-type headers
cirex-web b41bed8
Add cached response behavior tests
yuriiShmal 4b7d489
Merge branch 'main' into fix/content-type-headers
cirex-web 774107e
fix: bun.lock merge conflicts
cirex-web 8d1ebdf
fix: vitest should be a devDependency
cirex-web 011e56d
Fix Elysia cookie type import
yuriiShmal 95bea1f
Run build before tests
yuriiShmal cb0c53e
fix: pre-bundle html files if bunFullstack is true
cirex-web 898bb1d
test: add cached-path coverage for image content-type and etag suppre…
Aidanpgh ab2b092
chore: upd example/index.html with bunFullstack option
cirex-web c60864b
chore: fix accidental package.json test script reversion
cirex-web 670ff6d
fix: some more cleanup, performance benchmarking, mount root route be…
cirex-web 106cec0
chore: cleanup
cirex-web 138b506
test: add range request header test
cirex-web a564720
chore: cleanup test
cirex-web ebae90f
fix: refuse file requests outside of asset directory
cirex-web 310f90f
chore: minor tweaks for filepath normalization
cirex-web 3e543f8
fix: video and img assets on node
cirex-web b48fe33
chore: add audio for testing
cirex-web 2d938f7
test: add ci test workflow
cirex-web de0545a
chore: rename workflow
cirex-web 483fc41
chore: cleanup
cirex-web f6fd9dd
chore: some more cleanup
cirex-web c7f1d43
fix: url prefix arg should always use forward slash
cirex-web da80c86
chore: move devdeps below exports
cirex-web File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test code | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup bun | ||
| uses: oven-sh/setup-bun@v1 | ||
| with: | ||
| bun-version: latest | ||
|
|
||
| - name: Install packages | ||
| run: bun install | ||
|
|
||
| - name: Test | ||
| run: bun run test | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,4 +4,5 @@ node_modules | |
| .pnpm-debug.log | ||
| dist | ||
|
|
||
| build | ||
| build | ||
| cmueats-build | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { Bench } from 'tinybench' | ||
| import { Elysia } from 'elysia' | ||
| import { staticPlugin } from '../src' | ||
| import { req } from '../test/utils' | ||
|
|
||
| const bench = new Bench({ time: 10000 }) | ||
|
|
||
| const app = new Elysia().use( | ||
| staticPlugin({ | ||
| assets: 'public', | ||
| prefix: 'public', | ||
| indexHTML: true, | ||
| bunFullstack: false, | ||
| alwaysStatic: true | ||
| }) | ||
| ) | ||
| await app.modules | ||
| console.log(app.routes) | ||
| bench.add('route caching', async () => { | ||
| const htmlPaths = [ | ||
| '/public/html', | ||
| '/public/html/', | ||
| '/public/html/index.html', | ||
| '/public/html/index.html/' | ||
| ] | ||
| for (const path of htmlPaths) { | ||
| const res = await app.handle(req(path)) | ||
| await (await res.blob()).text() | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| }) | ||
|
|
||
| await bench.run() | ||
| console.table(bench.table()) | ||
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,21 @@ | ||
| import { Elysia } from 'elysia' | ||
| import { staticPlugin } from '../src/index' | ||
|
|
||
| const app = new Elysia() | ||
| .use( | ||
| await staticPlugin({ | ||
| prefix: '/', | ||
| bundleHTML: false | ||
| }) | ||
| ) | ||
| .listen(3000) | ||
|
|
||
| console.log(app.routes) | ||
|
|
||
| await app.modules | ||
| import { node } from '@elysiajs/node' | ||
| import { isBun } from '../src/utils' | ||
| ;(async () => { | ||
| const app = new Elysia(isBun ? {} : { adapter: node() }) | ||
| .use( | ||
| await staticPlugin({ | ||
| prefix: 'hi', | ||
| assets: 'public', | ||
| alwaysStatic: true, | ||
| bunFullstack: true, | ||
| decodeURI: false, | ||
| etag: false | ||
| // staticLimit: 1 | ||
| }) | ||
| ) | ||
| .listen(3005) | ||
| await app.modules | ||
| console.log(app.routes) | ||
| })() // no top-level awaits allowed for cjs (error triggered by `bun dev:node`) (idk how to fix this) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| <!DOCTYPE html> | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <title>Home!</title> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| console.log("hi") |
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
What is the latest stable version of Bun as of May 2026?💡 Result:
The latest stable Bun version as of May 10, 2026 is Bun v1.3.13.[1][2] Evidence: Bun’s official release landing page and the GitHub “Releases” page show v1.3.13 as the most recent release, dated 2026-04-20 (after which no newer stable release is shown in the results retrieved). [3][4]
Citations:
Pin Bun to a specific version instead of
latestfor deterministic CI builds~Using
latestmeans your CI runs are non-deterministic and could break randomly when a new Bun version drops♡ How reckless~ (¬‿¬) That's gonna cause all kinds of fun debugging when tests suddenly fail for no reason at all, ne~The current stable version as of May 2026 is v1.3.13 - pin to that instead of flying blind with
latest~🔧 Proposed fix to pin Bun version
- name: Setup bun uses: oven-sh/setup-bun@v1 with: - bun-version: latest + bun-version: 1.3.13📝 Committable suggestion
🤖 Prompt for AI Agents