aboutsummaryrefslogtreecommitdiff
path: root/bench/stream-file-upload-client/server-node.mjs
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-05-31 17:20:30 -0700
committerGravatar GitHub <noreply@github.com> 2023-05-31 17:20:30 -0700
commit4c0145437679f879329df69c9a56e395e74e8280 (patch)
tree77c317891d68344a0f04ac44ed90804793ec3a0e /bench/stream-file-upload-client/server-node.mjs
parent611f1d0e241d264747dda7288c018ab383906ccc (diff)
downloadbun-4c0145437679f879329df69c9a56e395e74e8280.tar.gz
bun-4c0145437679f879329df69c9a56e395e74e8280.tar.zst
bun-4c0145437679f879329df69c9a56e395e74e8280.zip
Make uploading files with `fetch()`fast (#3125)
* Make file uploads fast * Add benchmark * Update README.md * defaults * print * prettier * smaller * fix(path) fix parse behavior (#3134) * Add macro docs (#3139) * Add macro doc * Updates * Tweaks * Update doc * Update macro serialization doc * Update macro doc * `--no-macros` flag, disable macros in node_modules * invert base/filename internally (#3141) * always false * Fix broken test * Add a test sendfile() test with large file --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com> Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
Diffstat (limited to 'bench/stream-file-upload-client/server-node.mjs')
-rw-r--r--bench/stream-file-upload-client/server-node.mjs15
1 files changed, 15 insertions, 0 deletions
diff --git a/bench/stream-file-upload-client/server-node.mjs b/bench/stream-file-upload-client/server-node.mjs
new file mode 100644
index 000000000..10a7b19ed
--- /dev/null
+++ b/bench/stream-file-upload-client/server-node.mjs
@@ -0,0 +1,15 @@
+import { createServer } from "node:http";
+const server = createServer((req, res) => {
+ var chunkSize = 0;
+ req.on("data", chunk => {
+ chunkSize += chunk.byteLength;
+ });
+
+ req.on("end", () => {
+ console.log("Received", chunkSize, "bytes");
+ res.end(`${chunkSize}`);
+ });
+});
+server.listen(parseInt(process.env.PORT ?? "3000"), (err, port) => {
+ console.log(`http://localhost:${server.address().port}`);
+});