bun-http-server

Solid

Use when building HTTP servers with Bun.serve, handling requests/responses, implementing routing, creating REST APIs, or configuring fetch handlers.

API & Backend 162 stars 25 forks Updated 2 weeks ago MIT

Install

View on GitHub

Quality Score: 88/100

Stars 20%
74
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Bun HTTP Server Bun has a built-in high-performance HTTP server via `Bun.serve()`. ## Quick Start ```typescript const server = Bun.serve({ port: 3000, fetch(req) { return new Response("Hello World!"); }, }); console.log(`Server running at http://localhost:${server.port}`); ``` ## Request Handling ```typescript Bun.serve({ fetch(req) { const url = new URL(req.url); // Method console.log(req.method); // GET, POST, etc. // Path console.log(url.pathname); // /api/users // Query params console.log(url.searchParams.get("id")); // ?id=123 // Headers console.log(req.headers.get("Content-Type")); return new Response("OK"); }, }); ``` ## Body Parsing ```typescript Bun.serve({ async fetch(req) { // JSON const json = await req.json(); // Form data const form = await req.formData(); // Text const text = await req.text(); // ArrayBuffer const buffer = await req.arrayBuffer(); // Blob const blob = await req.blob(); return new Response("Received"); }, }); ``` ## Response Types ```typescript Bun.serve({ fetch(req) { const url = new URL(req.url); switch (url.pathname) { case "/json": return Response.json({ message: "Hello" }); case "/html": return new Response("<h1>Hello</h1>", { headers: { "Content-Type": "text/html" }, }); case "/redirect": return Response.redirect("/new-location", 302); cas...

Details

Author
secondsky
Repository
secondsky/claude-skills
Created
6 months ago
Last Updated
2 weeks ago
Language
TypeScript
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category