titanpl 4.0.1 → 4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "titanpl",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Titan Planet is a JavaScript-first backend framework that embeds JS actions into a Rust + Axum server and ships as a single native binary. Routes are compiled to static metadata; only actions run in the embedded JS runtime. No Node.js. No event loop in production.",
5
5
  "license": "ISC",
6
6
  "author": "ezetgalaxy",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/cli",
3
- "version": "5.0.5",
3
+ "version": "5.0.6",
4
4
  "description": "The unified CLI for Titan Planet. Use it to create, manage, build, and deploy high-performance backend projects.",
5
5
  "keywords": [
6
6
  "titanpl",
@@ -14,14 +14,33 @@ 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
 
22
+ # ------------------------------------------------
23
+ # Extract Titan Extensions (packages with titan.json)
24
+ # ------------------------------------------------
25
+ RUN mkdir -p /app/.ext && \
26
+ find node_modules -mindepth 2 -maxdepth 3 -type f -name "titan.json" | while read file; do \
27
+ pkg_dir=$(dirname "$file"); \
28
+ pkg_name=$(basename "$pkg_dir"); \
29
+ echo "Extracting Titan extension: $pkg_name"; \
30
+ cp -a "$pkg_dir" "/app/.ext/$pkg_name"; \
31
+ rm -rf "/app/.ext/$pkg_name/node_modules"; \
32
+ done
33
+
34
+ # ------------------------------------------------
35
+ # Copy ANY installed Titan Engine (Architecture agnostic)
36
+ # ------------------------------------------------
37
+ RUN mkdir -p /app/.ext/@titanpl && \
38
+ cp -r node_modules/@titanpl/engine-linux-* /app/.ext/@titanpl/
39
+
20
40
  COPY . .
21
41
 
22
- # Run the Titan release build step
23
- # This extracts extensions to .ext and prepares the 'build/' folder
24
- RUN npx titan build --release
42
+ # Run the Titan build step
43
+ RUN npx titan build
25
44
 
26
45
 
27
46
  # ================================================================
@@ -38,11 +57,31 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
38
57
  ca-certificates curl \
39
58
  && rm -rf /var/lib/apt/lists/*
40
59
 
41
- # Copy the entire release build folder prepared by Stage 1
42
- COPY --from=builder /app/build ./
60
+ # copy dist contents into /app/dist
61
+ COPY --from=builder /app/dist/ ./dist/
62
+
63
+ # titan extensions + engine
64
+ COPY --from=builder /app/.ext ./.ext
65
+
66
+ # runtime assets
67
+ COPY --from=builder /app/package.json ./package.json
68
+
69
+ # ---------------- OPTIONAL APP FOLDERS ----------------
70
+ # Static assets
71
+ # COPY --from=builder /app/app/static ./static
72
+
73
+ # Public assets
74
+ # COPY --from=builder /app/app/public ./public
75
+
76
+ # DB
77
+ # COPY --from=builder /app/app/db ./db
43
78
 
44
- # Ensure permissions
45
- RUN chown -R titan:titan /app
79
+ # CRITICAL SYSTEM SETUP:
80
+ # 1. Mandatory .env file (Engine requires it for config parsing)
81
+ # 2. Node modules symlink for extension JS dependency resolution
82
+ RUN echo "TITAN_DEV=0" > .env && \
83
+ ln -s /app/.ext /app/node_modules && \
84
+ chown -R titan:titan /app
46
85
 
47
86
  # Standard environment variables
48
87
  ENV HOST=0.0.0.0
@@ -52,9 +91,10 @@ ENV TITAN_DEV=0
52
91
  USER titan
53
92
  EXPOSE 5100
54
93
 
55
- # Health check
94
+ # Health check to ensure the server is alive
56
95
  HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
57
96
  CMD curl -f http://localhost:5100/ || exit 1
58
97
 
59
- # Start the server using the 'titan-server' binary created by the release process
60
- CMD ["./titan-server", "run", "dist"]
98
+ # DYNAMIC ENTRYPOINT: Finds the correct architecture binary and starts it
99
+ # This allows the SAME image to work on x64 vs ARM64 servers.
100
+ CMD ["/bin/sh", "-c", "exec $(find .ext/@titanpl/engine-linux-* -name titan-server -type f | head -n 1) run dist"]
@@ -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
 
@@ -472,20 +472,37 @@ fn native_db_connect(scope: &mut v8::HandleScope, args: v8::FunctionCallbackArgu
472
472
  }
473
473
 
474
474
  if DB_POOL.get().is_none() {
475
- let cfg: Config = conn_string.parse().unwrap();
475
+ let cfg: Config = match conn_string.parse() {
476
+ Ok(c) => c,
477
+ Err(e) => {
478
+ throw(scope, &format!("t.db.connect(): Invalid connection string: {}", e));
479
+ return;
480
+ }
481
+ };
476
482
  let mgr = Manager::new(cfg, NoTls);
477
483
 
478
- let pool = Pool::builder(mgr)
484
+ let pool = match Pool::builder(mgr)
479
485
  .max_size(max_size)
480
- .build()
481
- .unwrap();
486
+ .build() {
487
+ Ok(p) => p,
488
+ Err(e) => {
489
+ throw(scope, &format!("t.db.connect(): Failed to build connection pool: {}", e));
490
+ return;
491
+ }
492
+ };
482
493
 
483
494
  DB_POOL.set(pool).ok();
484
495
  }
485
496
 
486
497
  let db_conn_obj = v8::Object::new(scope);
487
498
 
488
- let query_fn = v8::Function::new(scope, native_db_query).unwrap();
499
+ let query_fn = match v8::Function::new(scope, native_db_query) {
500
+ Some(f) => f,
501
+ None => {
502
+ throw(scope, "t.db.connect(): Failed to create query function");
503
+ return;
504
+ }
505
+ };
489
506
  let query_key = v8_str(scope, "query");
490
507
  db_conn_obj.set(scope, query_key.into(), query_fn.into());
491
508