barejs 0.1.2 → 0.1.4
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/LICENSE +21 -0
- package/README.md +127 -80
- package/package.json +20 -7
- package/src/bare.ts +74 -66
- package/src/middleware/validators.ts +53 -0
- package/.github/workflows/bench.yml +0 -34
- package/benchmarks/index.ts +0 -31
- package/bun.lock +0 -63
- package/index.ts +0 -1
- package/tsconfig.json +0 -29
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 xarhang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,80 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
app.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
##
|
|
56
|
-
|
|
57
|
-
1.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
# 🚀 BareJS
|
|
2
|
+
BareJS is an ultra-high-performance web engine built on the Bun runtime, designed for minimalism and the lowest possible latency.
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+
[](https://xarhang.github.io/bareJS/dev/benchmarks/)
|
|
6
|
+
[](https://bun.sh)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 📊 Performance Benchmarks
|
|
11
|
+
|
|
12
|
+
Performance comparison between **BareJS**, **Elysia**, and **Hono**.
|
|
13
|
+
|
|
14
|
+
### 🚀 Latest Benchmark Results
|
|
15
|
+
*Awaiting automated update...*
|
|
16
|
+
|
|
17
|
+
<!-- MARKER: PERFORMANCE_TABLE_START -->
|
|
18
|
+
| Framework | Latency (Avg) | Speed Ratio |
|
|
19
|
+
| :--- | :--- | :--- |
|
|
20
|
+
| **BareJS** | **-- ns/iter** | **Baseline (1.0x)** |
|
|
21
|
+
| Elysia | -- ns/iter | --x slower |
|
|
22
|
+
| Hono | -- ns/iter | --x slower |
|
|
23
|
+
<!-- MARKER: PERFORMANCE_TABLE_END -->
|
|
24
|
+
|
|
25
|
+
<!-- NOTE: The table above is automatically updated via scripts/update-readme.ts -->
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
✨ **Features**
|
|
30
|
+
|
|
31
|
+
* **Ultra Low Latency:** Optimized to minimize processing overhead.
|
|
32
|
+
* **Zero Dependency:** Built natively for security and raw speed.
|
|
33
|
+
* **Optimized for Bun:** Leverages native Bun APIs for maximum performance.
|
|
34
|
+
* **Memory Efficient:** Minimal heap usage and clean garbage collection.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 📖 Documentation
|
|
39
|
+
|
|
40
|
+
### ⚡ The Core Engine
|
|
41
|
+
|
|
42
|
+
BareJS uses a **Static Route Compiler**. When you call `app.listen()`, BareJS transforms your routes into an optimized lookup table. This ensures routing complexity, meaning your app stays fast whether you have 10 routes or 10,000.
|
|
43
|
+
|
|
44
|
+
### 🏗️ Request Context
|
|
45
|
+
|
|
46
|
+
Every handler receives a `Context` object:
|
|
47
|
+
|
|
48
|
+
* `ctx.req`: The native Bun `Request`.
|
|
49
|
+
* `ctx.params`: Route parameters (e.g., `/user/:id`).
|
|
50
|
+
* `ctx.json(data)`: High-speed JSON response helper.
|
|
51
|
+
* `ctx.body`: The validated JSON payload (available when using validators).
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 🛠 Usage Examples
|
|
56
|
+
|
|
57
|
+
### 1. Basic Server
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { BareJS } from 'barejs';
|
|
61
|
+
|
|
62
|
+
const app = new BareJS();
|
|
63
|
+
|
|
64
|
+
app.get('/ping', (ctx) => ctx.json({ message: 'pong' }));
|
|
65
|
+
|
|
66
|
+
app.listen('0.0.0.0', 3000);
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 2. Validation (Choose Your Weapon)
|
|
71
|
+
|
|
72
|
+
BareJS allows you to use different validators for different routes.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { BareJS } from 'barejs';
|
|
76
|
+
import { typebox, zod, native } from 'barejs/middleware';
|
|
77
|
+
import { Type } from '@sinclair/typebox';
|
|
78
|
+
import { z } from 'zod';
|
|
79
|
+
|
|
80
|
+
const app = new BareJS();
|
|
81
|
+
|
|
82
|
+
// High Performance: TypeBox
|
|
83
|
+
const UserSchema = Type.Object({ name: Type.String() });
|
|
84
|
+
app.post('/tb', typebox(UserSchema), (ctx) => ctx.json(ctx.body));
|
|
85
|
+
|
|
86
|
+
// Popular Choice: Zod
|
|
87
|
+
const ZodSchema = z.object({ age: z.number() });
|
|
88
|
+
app.post('/zod', zod(ZodSchema), (ctx) => ctx.json(ctx.body));
|
|
89
|
+
|
|
90
|
+
// No Dependencies: Native
|
|
91
|
+
app.post('/native', native({ properties: { id: { type: 'number' } } }), (ctx) => ctx.json(ctx.body));
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 🛠 Getting Started
|
|
98
|
+
|
|
99
|
+
### Prerequisites
|
|
100
|
+
|
|
101
|
+
* **Bun** v1.0.0 or higher
|
|
102
|
+
|
|
103
|
+
### Installation
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
bun install barejs
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Running Benchmarks Locally
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
bun run bench
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## 🏗 Roadmap
|
|
118
|
+
|
|
119
|
+
* [x] Middleware Pattern Support (Chain Execution)
|
|
120
|
+
* [x] High-Speed Static Routing ( Lookup Table)
|
|
121
|
+
* [x] Schema Validation Integration
|
|
122
|
+
* [x] Modular Validator Support (TypeBox, Zod, Native)
|
|
123
|
+
* [ ] Full Plugin System
|
|
124
|
+
|
|
125
|
+
**Maintained by xarhang**
|
|
126
|
+
|
|
127
|
+
---
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "barejs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"author": "xarhang",
|
|
4
5
|
"description": "High-performance JIT-specialized web framework for Bun",
|
|
5
6
|
"main": "src/bare.ts",
|
|
6
7
|
"types": "src/bare.ts",
|
|
7
8
|
"type": "module",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/xarhang/barejs.git"
|
|
12
|
+
},
|
|
8
13
|
"scripts": {
|
|
9
14
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
15
|
"bench": "bun run benchmarks/index.ts",
|
|
@@ -14,16 +19,24 @@
|
|
|
14
19
|
"bun",
|
|
15
20
|
"framework",
|
|
16
21
|
"fastest",
|
|
17
|
-
"jit"
|
|
22
|
+
"jit",
|
|
23
|
+
"typebox",
|
|
24
|
+
"zod"
|
|
18
25
|
],
|
|
19
|
-
"author": "xarhang",
|
|
20
26
|
"license": "MIT",
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"@types/bun": "latest"
|
|
23
|
-
},
|
|
24
27
|
"dependencies": {
|
|
28
|
+
"@sinclair/typebox": "^0.34.46",
|
|
29
|
+
"zod": "^4.3.5"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/bun": "latest",
|
|
25
33
|
"elysia": "^1.4.21",
|
|
26
34
|
"hono": "^4.11.3",
|
|
27
35
|
"mitata": "^1.0.34"
|
|
28
|
-
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"src",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
]
|
|
29
42
|
}
|
package/src/bare.ts
CHANGED
|
@@ -1,66 +1,74 @@
|
|
|
1
|
-
export interface Context {
|
|
2
|
-
req: Request;
|
|
3
|
-
params: Record<string, string>;
|
|
4
|
-
json: (data: any) => Response;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
public
|
|
20
|
-
public
|
|
21
|
-
public
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
1
|
+
export interface Context {
|
|
2
|
+
req: Request;
|
|
3
|
+
params: Record<string, string>;
|
|
4
|
+
json: (data: any) => Response;
|
|
5
|
+
body?: any;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type Next = () => Promise<any> | any;
|
|
10
|
+
export type Middleware = (ctx: Context, next: Next) => any;
|
|
11
|
+
export type Handler = (ctx: Context) => any;
|
|
12
|
+
|
|
13
|
+
export class BareJS {
|
|
14
|
+
private routes: { method: string; path: string; handlers: (Middleware | Handler)[] }[] = [];
|
|
15
|
+
private globalMiddlewares: Middleware[] = [];
|
|
16
|
+
private compiledFetch?: (req: Request) => Promise<Response>;
|
|
17
|
+
private staticMap: Record<string, any> = {};
|
|
18
|
+
|
|
19
|
+
public post = (path: string, ...h: (Middleware | Handler)[]) => { this.routes.push({ method: "POST", path, handlers: h }); return this; };
|
|
20
|
+
public put = (path: string, ...h: (Middleware | Handler)[]) => { this.routes.push({ method: "PUT", path, handlers: h }); return this; };
|
|
21
|
+
public patch = (path: string, ...h: (Middleware | Handler)[]) => { this.routes.push({ method: "PATCH", path, handlers: h }); return this; };
|
|
22
|
+
public delete = (path: string, ...h: (Middleware | Handler)[]) => { this.routes.push({ method: "DELETE", path, handlers: h }); return this; };
|
|
23
|
+
public get = (path: string, ...h: (Middleware | Handler)[]) => { this.routes.push({ method: "GET", path, handlers: h }); return this; };
|
|
24
|
+
public use = (...m: Middleware[]) => { this.globalMiddlewares.push(...m); return this; };
|
|
25
|
+
|
|
26
|
+
public fetch = (req: Request): Promise<Response> | Response => {
|
|
27
|
+
if (!this.compiledFetch) this.compile();
|
|
28
|
+
return this.compiledFetch!(req);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private compile() {
|
|
32
|
+
this.routes.forEach((route) => {
|
|
33
|
+
const chain = (ctx: Context) => {
|
|
34
|
+
let idx = 0;
|
|
35
|
+
const middlewares = [...this.globalMiddlewares, ...route.handlers];
|
|
36
|
+
const next = (): any => {
|
|
37
|
+
const handler = middlewares[idx++];
|
|
38
|
+
if (!handler) return;
|
|
39
|
+
return handler(ctx, next);
|
|
40
|
+
};
|
|
41
|
+
return next();
|
|
42
|
+
};
|
|
43
|
+
this.staticMap[`${route.method}:${route.path}`] = chain;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const fnBody = `
|
|
47
|
+
const staticMap = this.staticMap;
|
|
48
|
+
const EMPTY_PARAMS = Object.freeze({});
|
|
49
|
+
const jsonHeader = { "content-type": "application/json" };
|
|
50
|
+
return (req) => {
|
|
51
|
+
const url = req.url;
|
|
52
|
+
const pathStart = url.indexOf('/', 8);
|
|
53
|
+
const path = pathStart === -1 ? '/' : url.substring(pathStart);
|
|
54
|
+
const key = req.method + ":" + path;
|
|
55
|
+
const runner = staticMap[key];
|
|
56
|
+
if (runner) {
|
|
57
|
+
const ctx = { req, params: EMPTY_PARAMS, json: (d) => new Response(JSON.stringify(d), { headers: jsonHeader }) };
|
|
58
|
+
return runner(ctx);
|
|
59
|
+
}
|
|
60
|
+
return new Response('404 Not Found', { status: 404 });
|
|
61
|
+
};`;
|
|
62
|
+
this.compiledFetch = new Function(fnBody).bind(this)();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
listen(ip: string = '0.0.0.0', port: number = 3000) {
|
|
66
|
+
this.compile();
|
|
67
|
+
console.log(`🚀 BareJS running at http://${ip}:${port}`);
|
|
68
|
+
return Bun.serve({
|
|
69
|
+
hostname: ip,
|
|
70
|
+
port,
|
|
71
|
+
fetch: (req) => this.compiledFetch!(req),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as Compiler from '@sinclair/typebox/compiler';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 1. TypeBox Validator: Highest Performance (JIT Optimized)
|
|
5
|
+
* Best for: Production and Benchmarking
|
|
6
|
+
*/
|
|
7
|
+
export const typebox = (schema: any) => {
|
|
8
|
+
const check = Compiler.TypeCompiler.Compile(schema);
|
|
9
|
+
return async (ctx: any, next: any) => {
|
|
10
|
+
try {
|
|
11
|
+
const body = await ctx.req.json();
|
|
12
|
+
if (!check.Check(body)) return new Response("TypeBox Validation Failed", { status: 400 });
|
|
13
|
+
ctx.body = body;
|
|
14
|
+
return next();
|
|
15
|
+
} catch { return new Response("Invalid JSON", { status: 400 }); }
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 2. Native Validator: Zero Dependency
|
|
21
|
+
* Best for: Avoiding Runtime bugs or keeping the bundle lightweight.
|
|
22
|
+
*/
|
|
23
|
+
export const native = (schema: any) => {
|
|
24
|
+
const properties = schema.properties || {};
|
|
25
|
+
const keys = Object.keys(properties);
|
|
26
|
+
return async (ctx: any, next: any) => {
|
|
27
|
+
try {
|
|
28
|
+
const body = await ctx.req.json();
|
|
29
|
+
for (const key of keys) {
|
|
30
|
+
if (typeof body[key] !== properties[key].type)
|
|
31
|
+
return new Response(`Native Validation Failed: ${key} is not ${properties[key].type}`, { status: 400 });
|
|
32
|
+
}
|
|
33
|
+
ctx.body = body;
|
|
34
|
+
return next();
|
|
35
|
+
} catch { return new Response("Invalid JSON", { status: 400 }); }
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 3. Zod Validator: Best Developer Experience
|
|
41
|
+
* Note: Requires 'npm install zod'
|
|
42
|
+
*/
|
|
43
|
+
export const zod = (schema: any) => {
|
|
44
|
+
return async (ctx: any, next: any) => {
|
|
45
|
+
try {
|
|
46
|
+
const body = await ctx.req.json();
|
|
47
|
+
const result = schema.safeParse(body);
|
|
48
|
+
if (!result.success) return new Response(JSON.stringify(result.error), { status: 400 });
|
|
49
|
+
ctx.body = result.data;
|
|
50
|
+
return next();
|
|
51
|
+
} catch { return new Response("Invalid JSON", { status: 400 }); }
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
name: Performance Benchmark
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches: [ main ]
|
|
5
|
-
|
|
6
|
-
jobs:
|
|
7
|
-
benchmark:
|
|
8
|
-
name: Run Benchmark
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v4
|
|
12
|
-
- uses: oven-sh/setup-bun@v1
|
|
13
|
-
|
|
14
|
-
- name: Install dependencies
|
|
15
|
-
run: bun install
|
|
16
|
-
|
|
17
|
-
- name: Run Benchmarks
|
|
18
|
-
run: |
|
|
19
|
-
# รัน server benchmark ในพื้นหลัง
|
|
20
|
-
bun benchmarks/index.ts &
|
|
21
|
-
# รอให้ server พร้อม
|
|
22
|
-
sleep 5
|
|
23
|
-
# ใช้ bombardier ยิงและเก็บผลเป็น JSON
|
|
24
|
-
docker run --net=host alpine/bombardier -c 50 -d 10s -l http://localhost:3000/bench > result.json
|
|
25
|
-
|
|
26
|
-
- name: Store benchmark result
|
|
27
|
-
uses: benchmark-action/github-action-benchmark@v1
|
|
28
|
-
with:
|
|
29
|
-
tool: 'customBiggerIsBetter'
|
|
30
|
-
output-file-path: result.json
|
|
31
|
-
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
32
|
-
auto-push: true
|
|
33
|
-
# แสดงผลในหน้า GitHub Pages (Optional)
|
|
34
|
-
comment-always: true
|
package/benchmarks/index.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { run, bench, group } from "mitata";
|
|
2
|
-
import { BareJS } from "../src/bare";
|
|
3
|
-
import { Elysia } from "elysia";
|
|
4
|
-
import { Hono } from "hono";
|
|
5
|
-
|
|
6
|
-
// Setup servers... (โค้ดเหมือนเดิม)
|
|
7
|
-
// แต่เปลี่ยนจากการ listen ค้างไว้ เป็นการใช้เครื่องมือวัดผลโดยตรง:
|
|
8
|
-
|
|
9
|
-
group("Web Framework Speed Test", () => {
|
|
10
|
-
const payload = { message: "bench" };
|
|
11
|
-
|
|
12
|
-
const bare = new BareJS();
|
|
13
|
-
bare.get("/", () => payload);
|
|
14
|
-
|
|
15
|
-
const elysia = new Elysia().get("/", () => payload);
|
|
16
|
-
const hono = new Hono().get("/", (c) => c.json(payload));
|
|
17
|
-
|
|
18
|
-
bench("BareJS (Your Engine)", async () => {
|
|
19
|
-
await bare.fetch(new Request("http://localhost/"));
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
bench("Elysia", async () => {
|
|
23
|
-
await elysia.handle(new Request("http://localhost/"));
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
bench("Hono", async () => {
|
|
27
|
-
await hono.fetch(new Request("http://localhost/"));
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
await run();
|
package/bun.lock
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"lockfileVersion": 1,
|
|
3
|
-
"workspaces": {
|
|
4
|
-
"": {
|
|
5
|
-
"name": "barejs-release",
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"elysia": "^1.4.21",
|
|
8
|
-
"hono": "^4.11.3",
|
|
9
|
-
"mitata": "^1.0.34",
|
|
10
|
-
},
|
|
11
|
-
"devDependencies": {
|
|
12
|
-
"@types/bun": "latest",
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
"packages": {
|
|
17
|
-
"@borewit/text-codec": ["@borewit/text-codec@0.2.1", "", {}, "sha512-k7vvKPbf7J2fZ5klGRD9AeKfUvojuZIQ3BT5u7Jfv+puwXkUBUT5PVyMDfJZpy30CBDXGMgw7fguK/lpOMBvgw=="],
|
|
18
|
-
|
|
19
|
-
"@sinclair/typebox": ["@sinclair/typebox@0.34.46", "", {}, "sha512-kiW7CtS/NkdvTUjkjUJo7d5JsFfbJ14YjdhDk9KoEgK6nFjKNXZPrX0jfLA8ZlET4cFLHxOZ/0vFKOP+bOxIOQ=="],
|
|
20
|
-
|
|
21
|
-
"@tokenizer/inflate": ["@tokenizer/inflate@0.4.1", "", { "dependencies": { "debug": "^4.4.3", "token-types": "^6.1.1" } }, "sha512-2mAv+8pkG6GIZiF1kNg1jAjh27IDxEPKwdGul3snfztFerfPGI1LjDezZp3i7BElXompqEtPmoPx6c2wgtWsOA=="],
|
|
22
|
-
|
|
23
|
-
"@tokenizer/token": ["@tokenizer/token@0.3.0", "", {}, "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A=="],
|
|
24
|
-
|
|
25
|
-
"@types/bun": ["@types/bun@1.3.5", "", { "dependencies": { "bun-types": "1.3.5" } }, "sha512-RnygCqNrd3srIPEWBd5LFeUYG7plCoH2Yw9WaZGyNmdTEei+gWaHqydbaIRkIkcbXwhBT94q78QljxN0Sk838w=="],
|
|
26
|
-
|
|
27
|
-
"@types/node": ["@types/node@25.0.3", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-W609buLVRVmeW693xKfzHeIV6nJGGz98uCPfeXI1ELMLXVeKYZ9m15fAMSaUPBHYLGFsVRcMmSCksQOrZV9BYA=="],
|
|
28
|
-
|
|
29
|
-
"bun-types": ["bun-types@1.3.5", "", { "dependencies": { "@types/node": "*" } }, "sha512-inmAYe2PFLs0SUbFOWSVD24sg1jFlMPxOjOSSCYqUgn4Hsc3rDc7dFvfVYjFPNHtov6kgUeulV4SxbuIV/stPw=="],
|
|
30
|
-
|
|
31
|
-
"cookie": ["cookie@1.1.1", "", {}, "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ=="],
|
|
32
|
-
|
|
33
|
-
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
|
|
34
|
-
|
|
35
|
-
"elysia": ["elysia@1.4.21", "", { "dependencies": { "cookie": "^1.1.1", "exact-mirror": "^0.2.6", "fast-decode-uri-component": "^1.0.1", "memoirist": "^0.4.0" }, "peerDependencies": { "@sinclair/typebox": ">= 0.34.0 < 1", "@types/bun": ">= 1.2.0", "file-type": ">= 20.0.0", "openapi-types": ">= 12.0.0", "typescript": ">= 5.0.0" }, "optionalPeers": ["@types/bun", "typescript"] }, "sha512-bGSbPSGnkWbO0qUDKS5Q+6iEewBdMmIiJ8F0li4djZ6WjpixUQouOzePYscG1Lemdv6pZpFi1YPfI/kjeq2voA=="],
|
|
36
|
-
|
|
37
|
-
"exact-mirror": ["exact-mirror@0.2.6", "", { "peerDependencies": { "@sinclair/typebox": "^0.34.15" }, "optionalPeers": ["@sinclair/typebox"] }, "sha512-7s059UIx9/tnOKSySzUk5cPGkoILhTE4p6ncf6uIPaQ+9aRBQzQjc9+q85l51+oZ+P6aBxh084pD0CzBQPcFUA=="],
|
|
38
|
-
|
|
39
|
-
"fast-decode-uri-component": ["fast-decode-uri-component@1.0.1", "", {}, "sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg=="],
|
|
40
|
-
|
|
41
|
-
"file-type": ["file-type@21.3.0", "", { "dependencies": { "@tokenizer/inflate": "^0.4.1", "strtok3": "^10.3.4", "token-types": "^6.1.1", "uint8array-extras": "^1.4.0" } }, "sha512-8kPJMIGz1Yt/aPEwOsrR97ZyZaD1Iqm8PClb1nYFclUCkBi0Ma5IsYNQzvSFS9ib51lWyIw5mIT9rWzI/xjpzA=="],
|
|
42
|
-
|
|
43
|
-
"hono": ["hono@4.11.3", "", {}, "sha512-PmQi306+M/ct/m5s66Hrg+adPnkD5jiO6IjA7WhWw0gSBSo1EcRegwuI1deZ+wd5pzCGynCcn2DprnE4/yEV4w=="],
|
|
44
|
-
|
|
45
|
-
"ieee754": ["ieee754@1.2.1", "", {}, "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="],
|
|
46
|
-
|
|
47
|
-
"memoirist": ["memoirist@0.4.0", "", {}, "sha512-zxTgA0mSYELa66DimuNQDvyLq36AwDlTuVRbnQtB+VuTcKWm5Qc4z3WkSpgsFWHNhexqkIooqpv4hdcqrX5Nmg=="],
|
|
48
|
-
|
|
49
|
-
"mitata": ["mitata@1.0.34", "", {}, "sha512-Mc3zrtNBKIMeHSCQ0XqRLo1vbdIx1wvFV9c8NJAiyho6AjNfMY8bVhbS12bwciUdd1t4rj8099CH3N3NFahaUA=="],
|
|
50
|
-
|
|
51
|
-
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
|
52
|
-
|
|
53
|
-
"openapi-types": ["openapi-types@12.1.3", "", {}, "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw=="],
|
|
54
|
-
|
|
55
|
-
"strtok3": ["strtok3@10.3.4", "", { "dependencies": { "@tokenizer/token": "^0.3.0" } }, "sha512-KIy5nylvC5le1OdaaoCJ07L+8iQzJHGH6pWDuzS+d07Cu7n1MZ2x26P8ZKIWfbK02+XIL8Mp4RkWeqdUCrDMfg=="],
|
|
56
|
-
|
|
57
|
-
"token-types": ["token-types@6.1.2", "", { "dependencies": { "@borewit/text-codec": "^0.2.1", "@tokenizer/token": "^0.3.0", "ieee754": "^1.2.1" } }, "sha512-dRXchy+C0IgK8WPC6xvCHFRIWYUbqqdEIKPaKo/AcTUNzwLTK6AH7RjdLWsEZcAN/TBdtfUw3PYEgPr5VPr6ww=="],
|
|
58
|
-
|
|
59
|
-
"uint8array-extras": ["uint8array-extras@1.5.0", "", {}, "sha512-rvKSBiC5zqCCiDZ9kAOszZcDvdAHwwIKJG33Ykj43OKcWsnmcBRL09YTU4nOeHZ8Y2a7l1MgTd08SBe9A8Qj6A=="],
|
|
60
|
-
|
|
61
|
-
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
|
|
62
|
-
}
|
|
63
|
-
}
|
package/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log("Hello via Bun!");
|
package/tsconfig.json
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
// Environment setup & latest features
|
|
4
|
-
"lib": ["ESNext"],
|
|
5
|
-
"target": "ESNext",
|
|
6
|
-
"module": "Preserve",
|
|
7
|
-
"moduleDetection": "force",
|
|
8
|
-
"jsx": "react-jsx",
|
|
9
|
-
"allowJs": true,
|
|
10
|
-
|
|
11
|
-
// Bundler mode
|
|
12
|
-
"moduleResolution": "bundler",
|
|
13
|
-
"allowImportingTsExtensions": true,
|
|
14
|
-
"verbatimModuleSyntax": true,
|
|
15
|
-
"noEmit": true,
|
|
16
|
-
|
|
17
|
-
// Best practices
|
|
18
|
-
"strict": true,
|
|
19
|
-
"skipLibCheck": true,
|
|
20
|
-
"noFallthroughCasesInSwitch": true,
|
|
21
|
-
"noUncheckedIndexedAccess": true,
|
|
22
|
-
"noImplicitOverride": true,
|
|
23
|
-
|
|
24
|
-
// Some stricter flags (disabled by default)
|
|
25
|
-
"noUnusedLocals": false,
|
|
26
|
-
"noUnusedParameters": false,
|
|
27
|
-
"noPropertyAccessFromIndexSignature": false
|
|
28
|
-
}
|
|
29
|
-
}
|