titanpl-sdk 2.0.2 → 3.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.
@@ -0,0 +1,39 @@
1
+ // titan.js - Named exports for users who prefer imports over the global `t`
2
+
3
+ export const fetch = t.fetch;
4
+ export const log = t.log;
5
+ export const read = t.read;
6
+
7
+ // Authentication & Security
8
+ export const jwt = t.jwt;
9
+ export const password = t.password;
10
+
11
+ // Database
12
+ export const db = t.db;
13
+
14
+ // File System & Path
15
+ export const fs = t.fs;
16
+ export const path = t.path;
17
+
18
+ // Crypto & Buffer
19
+ export const crypto = t.crypto;
20
+ export const buffer = t.buffer;
21
+
22
+ // Storage & Sessions
23
+ export const ls = t.ls;
24
+ export const localStorage = t.localStorage;
25
+ export const session = t.session;
26
+ export const cookies = t.cookies;
27
+
28
+ // System
29
+ export const os = t.os;
30
+ export const net = t.net;
31
+ export const proc = t.proc;
32
+
33
+ // Utilities
34
+ export const time = t.time;
35
+ export const url = t.url;
36
+ export const response = t.response;
37
+ export const valid = t.valid;
38
+
39
+ export const defineAction = (handler) => handler;
@@ -1,4 +1,3 @@
1
-
2
1
  [package]
3
2
  name = "titan-server"
4
3
  version = "0.1.0"
@@ -11,7 +10,7 @@ reqwest = { version = "0.12.24", features = ["json", "rustls-tls", "gzip", "brot
11
10
  serde = { version = "1.0.228", features = ["derive"] }
12
11
  serde_json = "1.0.145"
13
12
  thiserror = "2.0.17"
14
- tokio = { version = "1.48.0", features = ["rt-multi-thread", "macros", "process"] }
13
+ tokio = { version = "1.48.0", features = ["rt-multi-thread", "macros", "process", "fs"] }
15
14
  tower-http = { version = "0.6.7", features = ["cors"] }
16
15
  tracing = "0.1.43"
17
16
  tracing-subscriber = "0.3.22"
@@ -30,3 +29,22 @@ dashmap = "6.1.0"
30
29
  bytes = "1.11.0"
31
30
  smallvec = "1.15.1"
32
31
  num_cpus = "1.17.0"
32
+
33
+ # Performance: Global Allocator
34
+ mimalloc = { version = "0.1", default-features = false }
35
+
36
+ # Static Analysis: OXC (Zero runtime cost, used at startup)
37
+ oxc = { version = "0.108", features = ["semantic"] }
38
+
39
+ # Release Profile
40
+ [profile.release]
41
+ opt-level = 3
42
+ lto = "fat"
43
+ codegen-units = 1
44
+ panic = "abort"
45
+ strip = true
46
+
47
+ # Dev Profile
48
+ [profile.dev]
49
+ opt-level = 0
50
+ debug = 1
@@ -1,3 +1,8 @@
1
+ //! Action Management and Dynamic Routing
2
+ //!
3
+ //! Handles resolution of action directories, scanning for available actions,
4
+ //! and matching dynamic routes (e.g. `/users/:id`).
5
+
1
6
  use std::collections::HashMap;
2
7
  use std::env;
3
8
  use std::path::{Path, PathBuf};
@@ -19,10 +24,7 @@ pub struct DynamicRoute {
19
24
  pub action: String,
20
25
  }
21
26
 
22
- // -------------------------
23
- // ACTION DIRECTORY RESOLUTION
24
- // -------------------------
25
-
27
+ /// Resolve the directory path where actions are stored.
26
28
  pub fn resolve_actions_dir() -> PathBuf {
27
29
  // Respect explicit override first
28
30
  if let Ok(override_dir) = env::var("TITAN_ACTIONS_DIR") {
@@ -78,8 +80,7 @@ pub fn find_actions_dir(project_root: &PathBuf) -> Option<PathBuf> {
78
80
  None
79
81
  }
80
82
 
81
- // Dynamic Matcher (Core Logic)
82
-
83
+ /// Match a dynamic route against the current request path.
83
84
  pub fn match_dynamic_route(
84
85
  method: &str,
85
86
  path: &str,
@@ -138,10 +139,7 @@ pub fn match_dynamic_route(
138
139
  None
139
140
  }
140
141
 
141
- // -------------------------
142
- // ACTION SCANNING
143
- // -------------------------
144
-
142
+ /// Scan the resolved actions directory and return a map of action names to file paths.
145
143
  pub fn scan_actions(root: &PathBuf) -> HashMap<String, PathBuf> {
146
144
  let mut map = HashMap::new();
147
145
 
@@ -1,6 +1,8 @@
1
+ //! Error handling utilities.
2
+
1
3
  use v8::JsError;
2
4
 
3
- // A helper to Format v8 Errors
5
+ /// A helper to Format v8 Errors
4
6
  pub fn format_js_error(err: JsError, action: &str) -> String {
5
7
  format!(
6
8
  "Action: {}\n{}",