forked from TechEmpower/FrameworkBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Bun runtime using TypeScript (TechEmpower#8416)
- Loading branch information
1 parent
b53c073
commit 42aecae
Showing
5 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,22 @@ | ||
# [Bun](https://bun.sh/) - A fast all-in-one JavaScript runtime | ||
|
||
## Description | ||
|
||
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable | ||
called `bun`. | ||
|
||
At its core is the Bun runtime, a fast JavaScript runtime designed as a drop-in replacement for | ||
Node.js. It's written in Zig and powered by JavaScriptCore under the hood, dramatically reducing | ||
startup times and memory usage. | ||
|
||
- [Bun Docs](https://bun.sh/docs) | ||
|
||
## Test URLs | ||
|
||
### Test 1: JSON Encoding | ||
|
||
http://localhost:8080/json | ||
|
||
### Test 2: Plaintext | ||
|
||
http://localhost:8080/plaintext |
This file contains 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,20 @@ | ||
{ | ||
"framework": "bun", | ||
"tests": [{ | ||
"default": { | ||
"json_url": "/json", | ||
"plaintext_url": "/plaintext", | ||
"port": 8080, | ||
"approach": "Realistic", | ||
"classification": "Platform", | ||
"language": "TypeScript", | ||
"flavor": "bun", | ||
"platform": "bun", | ||
"webserver": "None", | ||
"os": "Linux", | ||
"database_os": "Linux", | ||
"display_name": "bun", | ||
"versus": "nodejs" | ||
} | ||
}] | ||
} |
This file contains 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,13 @@ | ||
FROM oven/bun:1.0 | ||
|
||
EXPOSE 8080 | ||
|
||
WORKDIR /app | ||
|
||
USER bun | ||
|
||
COPY ./src . | ||
|
||
ENV NODE_ENV=production | ||
|
||
CMD ["bun", "index.ts"] |
This file contains 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,15 @@ | ||
[framework] | ||
name = "bun" | ||
|
||
[main] | ||
urls.plaintext = "/plaintext" | ||
urls.json = "/json" | ||
approach = "Realistic" | ||
classification = "Platform" | ||
database_os = "Linux" | ||
database = "None" | ||
os = "Linux" | ||
orm = "Raw" | ||
platform = "bun" | ||
webserver = "None" | ||
versus = "nodejs" |
This file contains 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,21 @@ | ||
const HELLO_WORLD_STR = "Hello, World!"; | ||
const options: ResponseInit = { headers: { "Server": "Bun" } }; | ||
|
||
const server = Bun.serve({ | ||
port: 8080, | ||
fetch(req: Request) { | ||
const { pathname } = new URL(req.url); | ||
|
||
if (pathname === "/json") { | ||
return Response.json({ message: HELLO_WORLD_STR }, options); | ||
} | ||
|
||
if (pathname === "/plaintext") { | ||
return new Response(HELLO_WORLD_STR, options); | ||
} | ||
|
||
return new Response("", { status: 404 }) | ||
}, | ||
}); | ||
|
||
console.log(`Listening on localhost:${server.port}`); |