titanpl 4.0.1 → 6.0.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.
@@ -14,13 +14,14 @@ ENV NODE_ENV=production
14
14
 
15
15
  COPY package.json package-lock.json* ./
16
16
 
17
- # Install dependencies (including optional engines)
17
+ # Install with optional dependencies so it grabs the correct engine for the Linux builder
18
+ RUN npm install -g @titanpl/cli
19
+
18
20
  RUN npm install --include=optional
19
21
 
20
22
  COPY . .
21
23
 
22
- # Run the Titan release build step
23
- # This extracts extensions to .ext and prepares the 'build/' folder
24
+ # Run the Titan release build step (generates a 'build' folder)
24
25
  RUN npx titan build --release
25
26
 
26
27
 
@@ -38,11 +39,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
38
39
  ca-certificates curl \
39
40
  && rm -rf /var/lib/apt/lists/*
40
41
 
41
- # Copy the entire release build folder prepared by Stage 1
42
- COPY --from=builder /app/build ./
42
+ # Copy EVERYTHING from the generated build folder into Stage 2
43
+ # This includes dist/, .ext/, package.json, .env, and the titan-server binary
44
+ COPY --from=builder /app/build/ ./
43
45
 
44
- # Ensure permissions
45
- RUN chown -R titan:titan /app
46
+ # CRITICAL SYSTEM SETUP:
47
+ # Ensure the worker threads can find the extensions through the symlink
48
+ RUN ln -s /app/.ext /app/node_modules && \
49
+ chown -R titan:titan /app
46
50
 
47
51
  # Standard environment variables
48
52
  ENV HOST=0.0.0.0
@@ -52,9 +56,9 @@ ENV TITAN_DEV=0
52
56
  USER titan
53
57
  EXPOSE 5100
54
58
 
55
- # Health check
59
+ # Health check to ensure the server is alive
56
60
  HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
57
61
  CMD curl -f http://localhost:5100/ || exit 1
58
62
 
59
- # Start the server using the 'titan-server' binary created by the release process
60
- CMD ["./titan-server", "run", "dist"]
63
+ # DYNAMIC ENTRYPOINT: Use the portable binary in the root of /app
64
+ CMD ["./titan-server", "start"]
@@ -78,7 +78,7 @@ docker run -p 5100:5100 my-titan-app
78
78
 
79
79
  ## 🌐 Community & Support
80
80
 
81
- - **Documentation**: [docs.titanpl.com](https://titanpl.vercel.app)
81
+ - **Documentation**: [titanpl.vercel.app](https://titanpl.vercel.app)
82
82
  - **GitHub**: [github.com/t8nlab/titanpl](https://github.com/t8nlab/titanpl)
83
83
  - **Discord**: [Join our community](https://discord.gg/titanpl)
84
84
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "{{name}}",
3
- "version": "2.0.4",
3
+ "version": "6.0.0",
4
4
  "description": "A Titan Planet extension",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "@titanpl/core": "latest",
19
19
  "chokidar": "^5.0.0",
20
20
  "esbuild": "^0.27.2",
21
- "titanpl-sdk": "2.0.4"
21
+ "titanpl-sdk": "6.0.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@tgrv/microgravity": "latest"
@@ -6,16 +6,16 @@
6
6
  "template": "js"
7
7
  },
8
8
  "dependencies": {
9
- "@titanpl/cli": "2.0.4",
10
- "@titanpl/route": "2.0.4",
11
- "@titanpl/native": "2.0.4",
9
+ "@titanpl/cli": "6.0.0",
10
+ "@titanpl/route": "6.0.0",
11
+ "@titanpl/native": "6.0.0",
12
12
  "@titanpl/core": "latest",
13
13
  "@titanpl/node": "latest",
14
- "@titanpl/packet": "2.0.4"
14
+ "@titanpl/packet": "6.0.0"
15
15
  },
16
16
  "optionalDependencies": {
17
- "@titanpl/engine-linux-x64": "2.0.5",
18
- "@titanpl/engine-win32-x64": "2.0.3"
17
+ "@titanpl/engine-linux-x64": "6.0.0",
18
+ "@titanpl/engine-win32-x64": "6.0.0"
19
19
  },
20
20
  "scripts": {
21
21
  "build": "titan build",
@@ -28,5 +28,5 @@
28
28
  "eslint": "^9.39.2",
29
29
  "eslint-plugin-titanpl": "latest"
30
30
  },
31
- "version": "2.0.4"
32
- }
31
+ "version": "6.0.0"
32
+ }
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "titanpl",
3
- "version": "2.0.4",
3
+ "version": "6.0.0",
4
4
  "description": "A Titan Planet server",
5
5
  "type": "module",
6
6
  "titan": {
7
7
  "template": "rust-js"
8
8
  },
9
9
  "dependencies": {
10
- "@titanpl/cli": "2.0.4",
11
- "@titanpl/route": "2.0.4",
12
- "@titanpl/native": "2.0.4",
10
+ "@titanpl/cli": "6.0.0",
11
+ "@titanpl/route": "6.0.0",
12
+ "@titanpl/native": "6.0.0",
13
13
  "@titanpl/core": "latest",
14
14
  "@titanpl/node": "latest"
15
15
  },
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "titanpl",
3
- "version": "2.0.4",
3
+ "version": "6.0.0",
4
4
  "description": "A Titan Planet server (Rust + TypeScript)",
5
5
  "type": "module",
6
6
  "titan": {
7
7
  "template": "rust-ts"
8
8
  },
9
9
  "dependencies": {
10
- "@titanpl/cli": "2.0.4",
11
- "@titanpl/route": "2.0.4",
12
- "@titanpl/native": "2.0.4",
10
+ "@titanpl/cli": "6.0.0",
11
+ "@titanpl/route": "6.0.0",
12
+ "@titanpl/native": "6.0.0",
13
13
  "@titanpl/core": "latest",
14
14
  "@titanpl/node": "latest",
15
15
  "typescript": "^5.0.0"
@@ -6,18 +6,18 @@
6
6
  "template": "ts"
7
7
  },
8
8
  "dependencies": {
9
- "@titanpl/cli": "2.0.4",
10
- "@titanpl/route": "2.0.4",
11
- "@titanpl/native": "2.0.4",
9
+ "@titanpl/cli": "6.0.0",
10
+ "@titanpl/route": "6.0.0",
11
+ "@titanpl/native": "6.0.0",
12
12
  "@titanpl/core": "latest",
13
13
  "@titanpl/node": "latest",
14
- "@titanpl/packet": "2.0.4",
14
+ "@titanpl/packet": "6.0.0",
15
15
  "typescript": "^5.0.0"
16
16
  },
17
17
  "optionalDependencies": {
18
18
  "@titanpl/engine-linux-arm64": "2.0.5",
19
- "@titanpl/engine-linux-x64": "2.0.5",
20
- "@titanpl/engine-win32-x64": "2.0.3"
19
+ "@titanpl/engine-linux-x64": "6.0.0",
20
+ "@titanpl/engine-win32-x64": "6.0.0"
21
21
  },
22
22
  "scripts": {
23
23
  "build": "titan build",
@@ -31,5 +31,5 @@
31
31
  "eslint-plugin-titanpl": "latest",
32
32
  "@typescript-eslint/parser": "^8.54.0"
33
33
  },
34
- "version": "2.0.4"
35
- }
34
+ "version": "6.0.0"
35
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "titanpl-sdk",
3
- "version": "2.0.4",
3
+ "version": "6.0.0",
4
4
  "description": "Development SDK for Titan Planet. Provides TypeScript type definitions for the global 't' runtime object and a 'lite' test-harness runtime for building and verifying extensions.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -360,7 +360,9 @@ fn native_log(scope: &mut v8::HandleScope, args: v8::FunctionCallbackArguments,
360
360
 
361
361
  fn native_jwt_sign(scope: &mut v8::HandleScope, args: v8::FunctionCallbackArguments, mut retval: v8::ReturnValue) {
362
362
  let payload_val = args.get(0);
363
- let json_str = v8::json::stringify(scope, payload_val).unwrap().to_rust_string_lossy(scope);
363
+ let json_str = v8::json::stringify(scope, payload_val)
364
+ .map(|s| s.to_rust_string_lossy(scope))
365
+ .unwrap_or_else(|| "{}".to_string());
364
366
  let mut payload: serde_json::Map<String, Value> = serde_json::from_str(&json_str).unwrap_or_default();
365
367
  let secret = v8_to_string(scope, args.get(1));
366
368
 
@@ -472,20 +474,40 @@ fn native_db_connect(scope: &mut v8::HandleScope, args: v8::FunctionCallbackArgu
472
474
  }
473
475
 
474
476
  if DB_POOL.get().is_none() {
475
- let cfg: Config = conn_string.parse().unwrap();
477
+ let cfg: Config = match conn_string.parse() {
478
+ Ok(c) => c,
479
+ Err(e) => {
480
+ let msg = format!("t.db.connect(): Invalid connection string: {}", e);
481
+ let message = v8::String::new(scope, &msg).unwrap_or_else(|| v8::String::new(scope, "Error").unwrap());
482
+ let exception = v8::Exception::error(scope, message);
483
+ scope.throw_exception(exception);
484
+ return;
485
+ }
486
+ };
476
487
  let mgr = Manager::new(cfg, NoTls);
477
488
 
478
- let pool = Pool::builder(mgr)
489
+ let pool = match Pool::builder(mgr)
479
490
  .max_size(max_size)
480
- .build()
481
- .unwrap();
491
+ .build() {
492
+ Ok(p) => p,
493
+ Err(e) => {
494
+ throw(scope, &format!("t.db.connect(): Failed to build connection pool: {}", e));
495
+ return;
496
+ }
497
+ };
482
498
 
483
499
  DB_POOL.set(pool).ok();
484
500
  }
485
501
 
486
502
  let db_conn_obj = v8::Object::new(scope);
487
503
 
488
- let query_fn = v8::Function::new(scope, native_db_query).unwrap();
504
+ let query_fn = match v8::Function::new(scope, native_db_query) {
505
+ Some(f) => f,
506
+ None => {
507
+ throw(scope, "t.db.connect(): Failed to create query function");
508
+ return;
509
+ }
510
+ };
489
511
  let query_key = v8_str(scope, "query");
490
512
  db_conn_obj.set(scope, query_key.into(), query_fn.into());
491
513
 
@@ -96,7 +96,7 @@ async fn handler(State(state): State<AppState>, req: Request<Body>) -> impl Into
96
96
  "Server-Timing",
97
97
  format!("reply;dur={:.2}", elapsed.as_secs_f64() * 1000.0)
98
98
  .parse()
99
- .unwrap(),
99
+ .unwrap_or_else(|_| axum::http::HeaderValue::from_static("")),
100
100
  );
101
101
 
102
102
  if log_enabled {
@@ -140,7 +140,7 @@ async fn handler(State(state): State<AppState>, req: Request<Body>) -> impl Into
140
140
  "Server-Timing",
141
141
  format!("fastpath;dur={:.2}", elapsed.as_secs_f64() * 1000.0)
142
142
  .parse()
143
- .unwrap(),
143
+ .unwrap_or_else(|_| axum::http::HeaderValue::from_static("")),
144
144
  );
145
145
 
146
146
  if log_enabled {
@@ -409,7 +409,7 @@ async fn handler(State(state): State<AppState>, req: Request<Body>) -> impl Into
409
409
  .join(", ");
410
410
  response
411
411
  .headers_mut()
412
- .insert("Server-Timing", server_timing.parse().unwrap());
412
+ .insert("Server-Timing", server_timing.parse().unwrap_or_else(|_| axum::http::HeaderValue::from_static("")));
413
413
  }
414
414
 
415
415
  // Logging