@rosyn/core 0.1.3 → 0.1.5
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/README.md +107 -0
- package/package.json +4 -3
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# @rosyn/core
|
|
2
|
+
|
|
3
|
+
Ultra-fast, type-safe web framework and HTTP routing engine for Bun and Node.js.
|
|
4
|
+
|
|
5
|
+
## Highlights
|
|
6
|
+
|
|
7
|
+
- Nanosecond-fast HTTP request matching with compiled route regexes.
|
|
8
|
+
- First-class Bun native server integration with fallback to standard Web APIs.
|
|
9
|
+
- Fully compatible with `fetch(Request): Promise<Response>`.
|
|
10
|
+
- Native schema validation and static TypeScript type inference via `@rosyn/schema`.
|
|
11
|
+
- Built-in middleware primitives: CORS, secure cookies, static file serving, and HTTP client.
|
|
12
|
+
- Zero unnecessary bloat or micro-package fragmentation.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bun add @rosyn/core @rosyn/schema
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or using pnpm / npm:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm add @rosyn/core @rosyn/schema
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { Rosyn, t } from "@rosyn/core";
|
|
30
|
+
|
|
31
|
+
const app = new Rosyn({ name: "my-service" });
|
|
32
|
+
|
|
33
|
+
app.get("/health", () => {
|
|
34
|
+
return { status: "ok", timestamp: Date.now() };
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
app.get("/users/:id", (ctx) => {
|
|
38
|
+
return {
|
|
39
|
+
userId: ctx.params.id,
|
|
40
|
+
query: ctx.query
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
app.post("/users", {
|
|
45
|
+
body: t.Object({
|
|
46
|
+
username: t.String(),
|
|
47
|
+
email: t.String()
|
|
48
|
+
})
|
|
49
|
+
}, async (ctx) => {
|
|
50
|
+
return {
|
|
51
|
+
created: true,
|
|
52
|
+
data: ctx.body
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
await app.listen(3000);
|
|
57
|
+
console.log("Server running on http://localhost:3000");
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Built-in Utilities
|
|
61
|
+
|
|
62
|
+
### CORS Support
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { Rosyn, cors } from "@rosyn/core";
|
|
66
|
+
|
|
67
|
+
const app = new Rosyn();
|
|
68
|
+
app.use(cors({ origin: "*", credentials: true }));
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Static Asset Serving
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { Rosyn, staticServe } from "@rosyn/core";
|
|
75
|
+
|
|
76
|
+
const app = new Rosyn();
|
|
77
|
+
app.use(staticServe({ root: "./public" }));
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Secure Cookies
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
app.get("/login", (ctx) => {
|
|
84
|
+
ctx.cookie("session_id", "secret_token_123", {
|
|
85
|
+
httpOnly: true,
|
|
86
|
+
secure: true,
|
|
87
|
+
sameSite: "strict",
|
|
88
|
+
maxAge: 3600
|
|
89
|
+
});
|
|
90
|
+
return { success: true };
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Route Grouping
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
const app = new Rosyn();
|
|
98
|
+
|
|
99
|
+
app.group("/api/v1", (api) => {
|
|
100
|
+
api.get("/items", () => [{ id: 1, name: "Item One" }]);
|
|
101
|
+
api.post("/items", (ctx) => ({ created: true, body: ctx.body }));
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
MIT © ROSYN Team
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rosyn/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "ROSYN Core Application Framework and HTTP Routing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"test": "vitest run"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@rosyn/schema": "
|
|
20
|
+
"@rosyn/schema": "^0.1.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"typescript": "^5.6.3",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
|
-
"dist"
|
|
37
|
+
"dist",
|
|
38
|
+
"README.md"
|
|
38
39
|
]
|
|
39
40
|
}
|