@kichu12348/bunify 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -2
- package/benchmarks/bun-raw.ts +0 -54
- package/benchmarks/bunify.ts +0 -43
- package/example.ts +0 -11
package/package.json
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kichu12348/bunify",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/kichu12348/bunify.git"
|
|
7
|
+
},
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/kichu12348/bunify/issues"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/kichu12348/bunify#readme",
|
|
5
12
|
"author": "Kichu",
|
|
6
13
|
"publishConfig": {
|
|
7
14
|
"access": "public"
|
package/benchmarks/bun-raw.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const server = Bun.serve({
|
|
2
|
-
port: 3001,
|
|
3
|
-
async fetch(req) {
|
|
4
|
-
const url = new URL(req.url);
|
|
5
|
-
|
|
6
|
-
// 1. Simulate Middleware (headers added to all routes)
|
|
7
|
-
const headers = new Headers();
|
|
8
|
-
headers.set("X-Benchmark-Time", Date.now().toString());
|
|
9
|
-
|
|
10
|
-
if (req.method === "GET") {
|
|
11
|
-
// 2. Simple GET
|
|
12
|
-
if (url.pathname === "/") {
|
|
13
|
-
headers.set("Content-Type", "application/json");
|
|
14
|
-
return new Response(JSON.stringify({ message: "Hello, World!" }), {
|
|
15
|
-
headers,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// 3. Query params map handler
|
|
20
|
-
if (url.pathname === "/search") {
|
|
21
|
-
headers.set("Content-Type", "application/json");
|
|
22
|
-
const q = url.searchParams.get("q") || "none";
|
|
23
|
-
return new Response(JSON.stringify({ results: q }), { headers });
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// 4. Larger JSON Payload
|
|
27
|
-
if (url.pathname === "/data") {
|
|
28
|
-
headers.set("Content-Type", "application/json");
|
|
29
|
-
return new Response(
|
|
30
|
-
JSON.stringify({
|
|
31
|
-
items: [
|
|
32
|
-
{ id: 1, name: "Item A" },
|
|
33
|
-
{ id: 2, name: "Item B" },
|
|
34
|
-
{ id: 3, name: "Item C" },
|
|
35
|
-
],
|
|
36
|
-
status: "ok",
|
|
37
|
-
}),
|
|
38
|
-
{ headers },
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// 5. POST body JSON
|
|
44
|
-
if (req.method === "POST" && url.pathname === "/echo") {
|
|
45
|
-
const body = await req.json();
|
|
46
|
-
headers.set("Content-Type", "application/json");
|
|
47
|
-
return new Response(JSON.stringify(body), { status: 201, headers });
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return new Response("Not Found", { status: 404 });
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
console.log(`Raw Bun server listening on ${server.hostname}:${server.port}`);
|
package/benchmarks/bunify.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Bunify } from "../src/core";
|
|
2
|
-
|
|
3
|
-
const app = new Bunify();
|
|
4
|
-
|
|
5
|
-
// 1. App-level Middleware
|
|
6
|
-
app.use(async (req, reply, next) => {
|
|
7
|
-
reply.headers("X-Benchmark-Time", Date.now().toString());
|
|
8
|
-
return next();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
// 2. Simple GET
|
|
12
|
-
app.get("/", () => {
|
|
13
|
-
return { message: "Hello, World!" };
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// 3. Query params map handler
|
|
17
|
-
app.get("/search", (req) => {
|
|
18
|
-
return {
|
|
19
|
-
results: req.query.q || "none",
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// 4. Larger JSON Payload
|
|
24
|
-
app.get("/data", () => {
|
|
25
|
-
return {
|
|
26
|
-
items: [
|
|
27
|
-
{ id: 1, name: "Item A" },
|
|
28
|
-
{ id: 2, name: "Item B" },
|
|
29
|
-
{ id: 3, name: "Item C" },
|
|
30
|
-
],
|
|
31
|
-
status: "ok",
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// 5. POST body JSON
|
|
36
|
-
app.post("/echo", async (req, reply) => {
|
|
37
|
-
const body = await req.json();
|
|
38
|
-
return reply.status(201).json(body);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
app.listen(3000, (url) => {
|
|
42
|
-
console.log(`Bunify listening on ${url}`);
|
|
43
|
-
});
|
package/example.ts
DELETED