// @ts-nocheck // can't use @types/express or @types/body-parser because they // depend on @types/node which conflicts with bun-types import { test, expect } from "bun:test"; import express, { Application, Request, Response } from "express"; import { json } from "body-parser"; // Express uses iconv-lite test("iconv works", () => { var iconv = require("iconv-lite"); // Convert from an encoded buffer to a js string. var str = iconv.decode(Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f]), "win1251"); // Convert from a js string to an encoded buffer. var buf = iconv.encode("Sample input string", "win1251"); expect(str).toBe("hello"); expect(iconv.decode(buf, "win1251")).toBe("Sample input string"); // Check if encoding is supported expect(iconv.encodingExists("us-ascii")).toBe(true); }); // https://github.com/oven-sh/bun/issues/1913 test("httpServer", async () => { // Constants const PORT = 8412; // App handlers const app: Application = express(); const httpServer = require("http").createServer(app); app.on("error", err => { console.error(err); }); app.use(json()); var reached = false; // This throws a TypeError since it uses body-parser.json app.post("/ping", (request: Request, response: Response) => { expect(request.body).toEqual({ hello: "world" }); reached = true; response.status(200).send("POST - pong"); httpServer.close(); }); httpServer.listen(PORT); const resp = await fetch(`http://localhost:${PORT}/ping`, { method: "POST", body: JSON.stringify({ hello: "world" }), headers: { "Content-Type": "application/json", }, }); expect(await resp.text()).toBe("POST - pong"); expect(resp.status).toBe(200); expect(reached).toBe(true); }); tion value='ciro/spawn-abort-signal-rebased'>ciro/spawn-abort-signal-rebased Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/write.node.mjs (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-11-14Fix crash in web crypto. caused by refptrGravatar Jarred Sumner 3-2/+15
2022-11-14Fix crashiness with `process.env`Gravatar Jarred Sumner 2-27/+66
2022-11-14Fix string encoding issue in JSC C API usagesGravatar Jarred Sumner 3-139/+74
2022-11-14Prevent double-frees in log msgsGravatar Jarred Sumner 1-4/+15
2022-11-14Fix build errorGravatar Jarred SUmner 2-6/+1
2022-11-14Bugfixes and perf improvements to child_processGravatar Jarred SUmner 15-192/+416
2022-11-13use `write$NOCANCEL`, more loggingGravatar Jarred Sumner 3-12/+42
2022-11-13Add an e2e testGravatar Jarred Sumner 3-0/+52
2022-11-13Add missing `rmdir` exportGravatar Jarred Sumner 1-1/+2
2022-11-13Make node streams faster (#1502)Gravatar Jarred Sumner 23-406/+836
2022-11-13Fix incorrect exit status messageGravatar Jarred Sumner 1-3/+6
2022-11-12Fix syntax errorGravatar Jarred Sumner 1-2/+2
2022-11-12Set linker script to Bun 0.2Gravatar Jarred SUmner 1-1/+1
2022-11-12Fix infinite write loop on LinuxGravatar Jarred SUmner 3-44/+185
2022-11-12Add missing typeGravatar Jarred SUmner 1-1/+1
2022-11-12Add linker script to remove unwanted exports (#1499)Gravatar Tom Birch 2-1/+9
2022-11-12Fix memory leak in gzip pool + add test for gzip'd dataGravatar Jarred SUmner 7-62/+1530
2022-11-12Redo how we poll pipes (#1496)Gravatar Jarred Sumner 22-707/+1251
2022-11-11Add test that fails on linuxGravatar Jarred Sumner 7-21/+42
2022-11-112 framesGravatar Jarred Sumner 1-1/+1
2022-11-11Revert "Omit frame pointer"Gravatar Jarred Sumner 1-0/+1
2022-11-11Don't rm cachedGravatar Jarred Sumner 4-4/+0
2022-11-11try thisGravatar Jarred Sumner 4-0/+4
2022-11-11Update bun-linux-build.ymlGravatar Jarred Sumner 1-1/+0
2022-11-11try using git actionGravatar Jarred Sumner 4-7/+8
2022-11-11Remove with `git rm`Gravatar Jarred Sumner 2-8/+0