@ezetgalaxy/titan 26.7.4 → 26.8.0
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 +88 -201
- package/index.js +552 -489
- package/package.json +6 -5
- package/templates/js/_gitignore +37 -0
- package/templates/{package.json → js/package.json} +4 -1
- package/templates/js/server/action_map.json +3 -0
- package/templates/js/server/actions/hello.jsbundle +48 -0
- package/templates/js/server/routes.json +16 -0
- package/templates/js/server/src/actions_rust/mod.rs +15 -0
- package/templates/{server → js/server}/src/extensions.rs +149 -17
- package/templates/{titan → js/titan}/bundle.js +22 -9
- package/templates/js/titan/dev.js +194 -0
- package/templates/{titan → js/titan}/titan.js +25 -1
- package/templates/rust/Dockerfile +66 -0
- package/templates/rust/_dockerignore +3 -0
- package/templates/rust/_gitignore +37 -0
- package/templates/rust/app/actions/hello.js +5 -0
- package/templates/rust/app/actions/rust_hello.rs +14 -0
- package/templates/rust/app/app.js +11 -0
- package/templates/rust/app/titan.d.ts +101 -0
- package/templates/rust/jsconfig.json +19 -0
- package/templates/rust/package.json +13 -0
- package/templates/rust/server/Cargo.lock +2869 -0
- package/templates/rust/server/Cargo.toml +27 -0
- package/templates/rust/server/action_map.json +3 -0
- package/templates/rust/server/actions/hello.jsbundle +47 -0
- package/templates/rust/server/routes.json +22 -0
- package/templates/rust/server/src/action_management.rs +131 -0
- package/templates/rust/server/src/actions_rust/mod.rs +19 -0
- package/templates/rust/server/src/actions_rust/rust_hello.rs +14 -0
- package/templates/rust/server/src/errors.rs +10 -0
- package/templates/rust/server/src/extensions.rs +989 -0
- package/templates/rust/server/src/main.rs +443 -0
- package/templates/rust/server/src/utils.rs +33 -0
- package/templates/rust/titan/bundle.js +157 -0
- package/templates/rust/titan/dev.js +194 -0
- package/templates/rust/titan/titan.js +122 -0
- package/titanpl-sdk/package.json +1 -1
- package/titanpl-sdk/templates/Dockerfile +4 -17
- package/titanpl-sdk/templates/server/src/extensions.rs +218 -423
- package/titanpl-sdk/templates/server/src/main.rs +68 -134
- package/scripts/make_dist.sh +0 -71
- package/templates/titan/dev.js +0 -144
- /package/templates/{Dockerfile → js/Dockerfile} +0 -0
- /package/templates/{.dockerignore → js/_dockerignore} +0 -0
- /package/templates/{app → js/app}/actions/hello.js +0 -0
- /package/templates/{app → js/app}/app.js +0 -0
- /package/templates/{app → js/app}/titan.d.ts +0 -0
- /package/templates/{jsconfig.json → js/jsconfig.json} +0 -0
- /package/templates/{server → js/server}/Cargo.lock +0 -0
- /package/templates/{server → js/server}/Cargo.toml +0 -0
- /package/templates/{server → js/server}/src/action_management.rs +0 -0
- /package/templates/{server → js/server}/src/errors.rs +0 -0
- /package/templates/{server → js/server}/src/main.rs +0 -0
- /package/templates/{server → js/server}/src/utils.rs +0 -0
package/README.md
CHANGED
|
@@ -16,16 +16,18 @@
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
# TITAN PLANET 🚀
|
|
20
|
-
[](https://github.com/ezet-galaxy/titanpl)
|
|
19
|
+
# TITAN PLANET 🚀
|
|
21
20
|
|
|
21
|
+
[](https://www.npmjs.com/package/@ezetgalaxy/titan)
|
|
22
22
|
|
|
23
|
-
**JavaScript Simplicity. Rust Power. Zero Configuration.**
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
**JavaScript Simplicity. Native Rust Power. Zero Configuration.**
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
Titan Planet is a **JavaScript-first Backend Framework** that compiles your application into a single, high-performance native binary. It embeds a V8 JavaScript runtime directly into a specialized Rust + Axum server.
|
|
27
|
+
|
|
28
|
+
**Start with pure JavaScript.**
|
|
29
|
+
**Need raw power? Add Rust actions seamlessly.**
|
|
30
|
+
Titan handles the compilation, bundling, and routing automatically for both.
|
|
29
31
|
|
|
30
32
|
Titan = **JavaScript productivity × Rust performance × Zero DevOps**
|
|
31
33
|
|
|
@@ -36,253 +38,138 @@ Titan = **JavaScript productivity × Rust performance × Zero DevOps**
|
|
|
36
38
|
| Feature | Titan | Express/Nest | FastAPI | Bun |
|
|
37
39
|
| ------------------------------------ | ----- | ------------ | ------- | --------- |
|
|
38
40
|
| Native binary output | ✅ Yes | ❌ No | ❌ No | ❌ No |
|
|
39
|
-
| Rust
|
|
41
|
+
| Hybrid Rust + JS Actions | ✅ Yes | ❌ No | ❌ No | ❌ No |
|
|
40
42
|
| Pure JavaScript developer experience | ✅ Yes | ✅ Yes | ❌ No | ❌ Partial |
|
|
41
43
|
| Zero-config Docker deploy | ✅ Yes | ❌ No | ❌ No | ❌ No |
|
|
42
44
|
| Action-based architecture | ✅ Yes | ❌ No | ❌ No | ❌ No |
|
|
43
45
|
| Hot reload dev server | ✅ Yes | ❌ No | ❌ No | ❌ No |
|
|
44
46
|
|
|
45
|
-
Titan gives you:
|
|
46
|
-
|
|
47
|
-
* Native speed
|
|
48
|
-
* JS comfort
|
|
49
|
-
* Cloud-first deployment
|
|
50
|
-
* Full environment variable support
|
|
51
|
-
* Built-in HTTP client (`t.fetch`)
|
|
52
|
-
* Lightweight serverless-like actions
|
|
53
|
-
* Instant hot reload
|
|
54
|
-
* Zero configuration
|
|
55
|
-
* Single deployable binary
|
|
56
|
-
|
|
57
47
|
---
|
|
58
48
|
|
|
59
49
|
# 🚀 Quick Start
|
|
60
50
|
|
|
51
|
+
### 1. Prerequisites
|
|
52
|
+
* **Rust** (latest stable): [Install Rust](https://rust-lang.org/tools/install/)
|
|
53
|
+
* **Node.js** (v18+): Required for CLI and JS tooling.
|
|
61
54
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Install before using Titan:
|
|
65
|
-
|
|
66
|
-
### 1. Rust (latest stable)
|
|
67
|
-
|
|
68
|
-
[https://rust-lang.org/tools/install/](https://rust-lang.org/tools/install/)
|
|
69
|
-
|
|
70
|
-
### 2. Node.js (v18+)
|
|
71
|
-
|
|
72
|
-
Required for:
|
|
73
|
-
|
|
74
|
-
* Titan CLI
|
|
75
|
-
* esbuild
|
|
76
|
-
* JS → Rust compilation pipeline
|
|
77
|
-
|
|
78
|
-
Verify:
|
|
79
|
-
|
|
55
|
+
### 2. Install CLI
|
|
80
56
|
```bash
|
|
81
|
-
|
|
82
|
-
npm -v
|
|
83
|
-
rustc -V
|
|
57
|
+
npm install -g @ezetgalaxy/titan
|
|
84
58
|
```
|
|
85
59
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
### Install Titan CLI
|
|
89
|
-
|
|
60
|
+
### 3. Initialize & Run
|
|
90
61
|
```bash
|
|
91
|
-
|
|
62
|
+
titan init my-app
|
|
63
|
+
# Follow the interactive prompt to choose:
|
|
64
|
+
# - JavaScript (Standard)
|
|
65
|
+
# - Rust + JavaScript (Beta)
|
|
92
66
|
```
|
|
93
67
|
|
|
94
|
-
|
|
95
|
-
|
|
68
|
+
Inside your project:
|
|
96
69
|
```bash
|
|
97
|
-
titan init my-app
|
|
98
70
|
cd my-app
|
|
99
71
|
titan dev
|
|
100
72
|
```
|
|
101
73
|
|
|
102
|
-
Titan
|
|
74
|
+
You'll see the Titan Dev Server spin up:
|
|
75
|
+
```
|
|
76
|
+
Titan Planet v26.8.0 [ Dev Mode ]
|
|
77
|
+
|
|
78
|
+
Type: Rust + JS Actions
|
|
79
|
+
Hot Reload: Enabled
|
|
103
80
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
* Trigger instant reload
|
|
81
|
+
• Preparing runtime... Done
|
|
82
|
+
• A new orbit is ready for your app in 0.9s
|
|
83
|
+
• Your app is now orbiting Titan Planet
|
|
84
|
+
```
|
|
109
85
|
|
|
110
86
|
---
|
|
111
87
|
|
|
112
|
-
#
|
|
88
|
+
# ⚡ Hybrid Action System
|
|
113
89
|
|
|
114
|
-
|
|
90
|
+
Titan is unique because it allows you to write endpoints in **both** JavaScript and Rust within the same project.
|
|
115
91
|
|
|
116
|
-
|
|
117
|
-
|
|
92
|
+
### 🟡 JavaScript Actions (`app/actions/hello.js`)
|
|
93
|
+
Perfect for business logic, rapid prototyping, and IO-bound tasks.
|
|
94
|
+
```javascript
|
|
95
|
+
export function run(req) {
|
|
96
|
+
t.log("Handling user request...");
|
|
97
|
+
return {
|
|
98
|
+
message: "Hello from JavaScript!",
|
|
99
|
+
user_id: req.params.id
|
|
100
|
+
};
|
|
101
|
+
}
|
|
118
102
|
```
|
|
119
|
-
* Then
|
|
120
103
|
|
|
121
|
-
|
|
122
|
-
|
|
104
|
+
### 🔴 Rust Actions (Beta)
|
|
105
|
+
Perfect for heavy computation, encryption, image processing, or low-level system access.
|
|
106
|
+
> **Note:** The Native Rust Action API is currently in **Beta**.
|
|
107
|
+
```rust
|
|
108
|
+
use axum::{response::{IntoResponse, Json}, http::Request, body::Body};
|
|
109
|
+
use serde_json::json;
|
|
110
|
+
|
|
111
|
+
pub async fn run(req: Request<Body>) -> impl IntoResponse {
|
|
112
|
+
let result = heavy_computation();
|
|
113
|
+
t.log("Processed 1M records in Rust");
|
|
114
|
+
Json(json!({ "result": result }))
|
|
115
|
+
}
|
|
123
116
|
```
|
|
124
|
-
* ``tit update`` will update and add new features in your Titan project
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
# ✨ What Titan Can Do (New & Core Features)
|
|
128
|
-
|
|
129
|
-
Titan now includes a **complete runtime engine** with the following built-in capabilities:
|
|
130
|
-
|
|
131
|
-
### 🛣 Routing & HTTP
|
|
132
|
-
|
|
133
|
-
* Static routes (`/`, `/health`)
|
|
134
|
-
* Dynamic routes (`/user/:id<number>`)
|
|
135
|
-
* Typed route parameters
|
|
136
|
-
* Automatic method matching (GET / POST)
|
|
137
|
-
* Query parsing (`req.query`)
|
|
138
|
-
* Body parsing (`req.body`)
|
|
139
|
-
* Zero-config routing metadata generation
|
|
140
117
|
|
|
141
|
-
|
|
118
|
+
**Titan automatically detects, compiles, and routes both types.**
|
|
119
|
+
* `.js` files are bundled with esbuild.
|
|
120
|
+
* `.rs` files are compiled into the native binary.
|
|
121
|
+
* Both share the same `routes.json` configuration.
|
|
142
122
|
|
|
143
|
-
|
|
144
|
-
* Automatic action discovery and execution
|
|
145
|
-
* No `globalThis` required anymore
|
|
146
|
-
* Safe handling of `undefined` returns
|
|
147
|
-
* JSON serialization guardrails
|
|
148
|
-
* Action-scoped execution context
|
|
123
|
+
---
|
|
149
124
|
|
|
150
|
-
|
|
125
|
+
# ✨ Core Capabilities
|
|
151
126
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
* Environment variable access (`process.env`)
|
|
155
|
-
* No access to raw Node.js APIs (safe by default)
|
|
127
|
+
### 🔌 Unified Runtime API (`t`)
|
|
128
|
+
Both JS and Rust actions have access to the powerful `t` namespace:
|
|
156
129
|
|
|
157
|
-
|
|
130
|
+
* `t.fetch(url, options)` — High-performance HTTP client
|
|
131
|
+
* `t.log(msg)` — Sandboxed, structured logging
|
|
132
|
+
* `t.jwt.sign / verify` — Fast JWT operations
|
|
133
|
+
* `t.password.hash / verify` — Secure password handling
|
|
134
|
+
* `t.db` — Database access (coming soon)
|
|
158
135
|
|
|
159
|
-
|
|
136
|
+
### 🛣 Intelligent Routing
|
|
137
|
+
Define your routes in `routes.json`. Titan maps them to the correct action, regardless of language.
|
|
160
138
|
|
|
161
139
|
```json
|
|
162
140
|
{
|
|
163
|
-
"
|
|
164
|
-
"
|
|
165
|
-
"params": { "id": "90" },
|
|
166
|
-
"query": {},
|
|
167
|
-
"body": null,
|
|
168
|
-
|
|
169
|
-
"headers": {
|
|
170
|
-
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
|
171
|
-
"accept-encoding": "gzip, deflate, br, zstd",
|
|
172
|
-
"accept-language": "en-US,en;q=0.9",
|
|
173
|
-
"cache-control": "max-age=0",
|
|
174
|
-
"connection": "keep-alive",
|
|
175
|
-
"cookie": "",
|
|
176
|
-
"host": "localhost:3000",
|
|
177
|
-
"sec-ch-ua": "\"Google Chrome\";v=\"143\", \"Chromium\";v=\"143\", \"Not A(Brand\";v=\"24\"",
|
|
178
|
-
"sec-ch-ua-mobile": "?0",
|
|
179
|
-
"sec-ch-ua-platform": "\"Windows\"",
|
|
180
|
-
"sec-fetch-dest": "document",
|
|
181
|
-
"sec-fetch-mode": "navigate",
|
|
182
|
-
"sec-fetch-site": "none",
|
|
183
|
-
"sec-fetch-user": "?1",
|
|
184
|
-
"upgrade-insecure-requests": "1",
|
|
185
|
-
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36"
|
|
186
|
-
},
|
|
141
|
+
"/hello": "hello", // variable name matches filename (hello.js)
|
|
142
|
+
"/compute": "compute" // variable name matches filename (compute.rs)
|
|
187
143
|
}
|
|
188
144
|
```
|
|
189
145
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
* Serializable
|
|
195
|
-
* Identical across dev & production
|
|
196
|
-
|
|
197
|
-
---
|
|
198
|
-
|
|
199
|
-
### 🔥 Developer Experience
|
|
200
|
-
|
|
201
|
-
* Hot reload dev server (`titan dev`)
|
|
202
|
-
* Automatic rebundling of actions
|
|
203
|
-
* Automatic Rust server restart
|
|
204
|
-
* Colored request logs
|
|
205
|
-
* Per-route timing metrics
|
|
206
|
-
* Action-aware logs
|
|
207
|
-
|
|
208
|
-
Example runtime log:
|
|
209
|
-
|
|
210
|
-
```
|
|
211
|
-
[Titan] GET /user/90 → getUser (dynamic) in 0.42ms
|
|
212
|
-
[Titan] log(getUser): Fetching user 90
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
---
|
|
216
|
-
|
|
217
|
-
### 🧨 Error Handling & Diagnostics
|
|
218
|
-
|
|
219
|
-
* JavaScript runtime errors captured safely
|
|
220
|
-
* Action-aware error reporting
|
|
221
|
-
* Line & column hints from runtime
|
|
222
|
-
* Red-colored error logs
|
|
223
|
-
* No server crashes on user mistakes
|
|
224
|
-
* Safe fallback for `undefined` returns
|
|
225
|
-
|
|
226
|
-
---
|
|
227
|
-
|
|
228
|
-
### ⚙ Build & Deployment
|
|
229
|
-
|
|
230
|
-
* Native Rust binary output
|
|
231
|
-
* Zero-config Dockerfile generation
|
|
232
|
-
* Multi-stage optimized Docker builds
|
|
233
|
-
* Works on:
|
|
234
|
-
|
|
235
|
-
* Railway
|
|
236
|
-
* Fly.io
|
|
237
|
-
* Render
|
|
238
|
-
* VPS
|
|
239
|
-
* Kubernetes
|
|
240
|
-
* No Node.js required in production
|
|
146
|
+
### 🧩 Extensions System
|
|
147
|
+
Extend the runtime with custom Rust engines using **Titan Extensions**.
|
|
148
|
+
* `titan create ext <name>`: Scaffold a new extension.
|
|
149
|
+
* `titan run ext`: Test your extension in a lightweight harness.
|
|
241
150
|
|
|
242
151
|
---
|
|
243
152
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
### 🧩 Titan Extensions & Test Harness
|
|
153
|
+
# 📦 Deployment
|
|
247
154
|
|
|
248
|
-
Titan
|
|
155
|
+
Titan compiles your entire app—JS code, Rust code, and server logic—into a **single executable**.
|
|
249
156
|
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
|
|
253
|
-
* Links your extension to a temporary project.
|
|
254
|
-
* Generates a test suite to verify your extension's methods.
|
|
255
|
-
* Starts a live server to test extension logic in a real-world scenario.
|
|
157
|
+
* **Tiny Docker Images**: Alpine-based, ~20MB compressed.
|
|
158
|
+
* **Instant Startup**: No node_modules overhead.
|
|
159
|
+
* **Secure**: No access to system APIs from JS unless explicitly bridged.
|
|
256
160
|
|
|
257
161
|
---
|
|
258
162
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
export function getUser(req) {
|
|
265
|
-
t.log("User id:", req.params.id);
|
|
266
|
-
|
|
267
|
-
return {
|
|
268
|
-
id: Number(req.params.id),
|
|
269
|
-
method: req.method
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
That’s it.
|
|
275
|
-
No exports wiring. No globals. No boilerplate.
|
|
163
|
+
# 🧱 Architecture Note
|
|
164
|
+
Titan is **not** a Node.js framework. It is a Rust server that speaks JavaScript.
|
|
165
|
+
* **No Event Loop** for JS (Request/Response model).
|
|
166
|
+
* **No `require`** (Use raw imports or bundled dependencies).
|
|
167
|
+
* **True Isolation** per request.
|
|
276
168
|
|
|
277
169
|
---
|
|
278
170
|
|
|
279
|
-
# 📦 Version
|
|
280
|
-
|
|
281
171
|
**Titan v26 — Stable**
|
|
172
|
+
* Production-ready Hybrid Runtime
|
|
173
|
+
* Native Rust Performance
|
|
174
|
+
* Zero-Config Cloud Deployment
|
|
282
175
|
|
|
283
|
-
* Production-ready runtime
|
|
284
|
-
* Safe JS execution
|
|
285
|
-
* Native Rust performance
|
|
286
|
-
* Designed for cloud & AI workloads
|
|
287
|
-
|
|
288
|
-
---
|