@ezetgalaxy/titan 26.9.0 → 26.9.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.
Files changed (54) hide show
  1. package/README.md +39 -17
  2. package/index.js +227 -120
  3. package/package.json +17 -5
  4. package/templates/{js → common}/app/titan.d.ts +1 -1
  5. package/templates/{rust → rust-js}/package.json +1 -1
  6. package/templates/rust-ts/app/actions/hello.ts +10 -4
  7. package/templates/rust-ts/app/app.ts +1 -1
  8. package/templates/rust-ts/titan/bundle.js +15 -9
  9. package/templates/rust-ts/titan/dev.js +2 -2
  10. package/templates/rust-ts/titan/runtime.d.ts +1 -0
  11. package/templates/rust-ts/titan/runtime.js +1 -0
  12. package/templates/rust-ts/titan/titan.d.ts +117 -0
  13. package/templates/rust-ts/titan/titan.js +95 -95
  14. package/templates/ts/app/actions/hello.ts +2 -0
  15. package/templates/ts/app/app.ts +1 -1
  16. package/templates/ts/titan/builder.js +121 -0
  17. package/templates/ts/titan/bundle.js +9 -11
  18. package/templates/ts/titan/dev.js +2 -2
  19. package/templates/ts/titan/runtime.d.ts +1 -0
  20. package/templates/ts/titan/runtime.js +1 -0
  21. package/templates/ts/titan/titan.d.ts +117 -0
  22. package/templates/ts/titan/titan.js +95 -95
  23. package/titanpl-sdk/README.md +4 -4
  24. package/titanpl-sdk/bin/run.js +74 -77
  25. package/titanpl-sdk/package.json +1 -1
  26. package/templates/rust/Dockerfile +0 -66
  27. package/templates/rust/_dockerignore +0 -3
  28. package/templates/rust/_gitignore +0 -38
  29. package/templates/rust/app/titan.d.ts +0 -101
  30. package/templates/rust-ts/Dockerfile +0 -66
  31. package/templates/rust-ts/_dockerignore +0 -3
  32. package/templates/rust-ts/_gitignore +0 -38
  33. package/templates/rust-ts/app/titan.d.ts +0 -101
  34. package/templates/ts/Dockerfile +0 -66
  35. package/templates/ts/_dockerignore +0 -3
  36. package/templates/ts/_gitignore +0 -38
  37. package/templates/ts/app/titan.d.ts +0 -102
  38. /package/templates/{js → common}/Dockerfile +0 -0
  39. /package/templates/{js → common}/_dockerignore +0 -0
  40. /package/templates/{js → common}/_gitignore +0 -0
  41. /package/templates/{rust → rust-js}/app/actions/hello.js +0 -0
  42. /package/templates/{rust → rust-js}/app/actions/rust_hello.rs +0 -0
  43. /package/templates/{rust → rust-js}/app/app.js +0 -0
  44. /package/templates/{rust → rust-js}/jsconfig.json +0 -0
  45. /package/templates/{rust → rust-js}/server/Cargo.lock +0 -0
  46. /package/templates/{rust → rust-js}/server/Cargo.toml +0 -0
  47. /package/templates/{rust → rust-js}/server/src/action_management.rs +0 -0
  48. /package/templates/{rust → rust-js}/server/src/errors.rs +0 -0
  49. /package/templates/{rust → rust-js}/server/src/extensions.rs +0 -0
  50. /package/templates/{rust → rust-js}/server/src/main.rs +0 -0
  51. /package/templates/{rust → rust-js}/server/src/utils.rs +0 -0
  52. /package/templates/{rust → rust-js}/titan/bundle.js +0 -0
  53. /package/templates/{rust → rust-js}/titan/dev.js +0 -0
  54. /package/templates/{rust → rust-js}/titan/titan.js +0 -0
@@ -1,101 +0,0 @@
1
- export { };
2
-
3
- declare global {
4
- /**
5
- * TITAN TYPE DEFINITIONS
6
- * ----------------------
7
- * These types are globally available in your Titan project.
8
- */
9
-
10
- /**
11
- * The Titan Request Object passed to actions.
12
- */
13
- interface TitanRequest {
14
- body: any;
15
- method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
16
- path: string;
17
- headers: {
18
- host?: string;
19
- "content-type"?: string;
20
- "user-agent"?: string;
21
- authorization?: string;
22
- [key: string]: string | undefined;
23
- };
24
- params: Record<string, string>;
25
- query: Record<string, string>;
26
- }
27
-
28
- interface DbConnection {
29
- /**
30
- * Execute a SQL query.
31
- * @param sql The SQL query string.
32
- * @param params (Optional) Parameters for the query ($1, $2, etc).
33
- */
34
- query(sql: string, params?: any[]): any[];
35
- }
36
-
37
- /**
38
- * Define a Titan Action with type inference.
39
- * @example
40
- * export const hello = defineAction((req) => {
41
- * return req.headers;
42
- * });
43
- */
44
- function defineAction<T>(actionFn: (req: TitanRequest) => T): (req: TitanRequest) => T;
45
-
46
- /**
47
- * Titan Runtime Utilities
48
- */
49
- const t: {
50
- /**
51
- * Log messages to the server console with Titan formatting.
52
- */
53
- log(...args: any[]): void;
54
-
55
- /**
56
- * Read a file contents as string.
57
- * @param path Relative path to the file from project root.
58
- */
59
- read(path: string): string;
60
-
61
- fetch(url: string, options?: {
62
- method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
63
- headers?: Record<string, string>;
64
- body?: string | object;
65
- }): {
66
- ok: boolean;
67
- status?: number;
68
- body?: string;
69
- error?: string;
70
- };
71
-
72
- jwt: {
73
- sign(
74
- payload: object,
75
- secret: string,
76
- options?: { expiresIn?: string | number }
77
- ): string;
78
- verify(token: string, secret: string): any;
79
- };
80
-
81
- password: {
82
- hash(password: string): string;
83
- verify(password: string, hash: string): boolean;
84
- };
85
-
86
- db: {
87
- connect(url: string): DbConnection;
88
- };
89
-
90
- /**
91
- * Titan Validator (Zod-compatible)
92
- */
93
- valid: typeof import("@titanpl/valid");
94
- };
95
-
96
- /**
97
- * Global Request Object
98
- * Available automatically in actions.
99
- */
100
- var req: TitanRequest;
101
- }
@@ -1,66 +0,0 @@
1
- # ================================================================
2
- # STAGE 1 — Build Titan (JS → Rust)
3
- # ================================================================
4
- FROM rust:1.91.1 AS builder
5
-
6
- # Install Node for Titan CLI + bundler
7
- RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
8
- && apt-get install -y nodejs
9
-
10
- # Install Titan CLI (latest)
11
- RUN npm install -g @ezetgalaxy/titan@latest
12
-
13
- WORKDIR /app
14
-
15
- # Copy project files
16
- COPY . .
17
-
18
- # Install JS dependencies (needed for Titan DSL + bundler)
19
- RUN npm install
20
-
21
- SHELL ["/bin/bash", "-c"]
22
-
23
- # Extract Titan extensions into .ext
24
- RUN mkdir -p /app/.ext && \
25
- find /app/node_modules -maxdepth 5 -type f -name "titan.json" -print0 | \
26
- while IFS= read -r -d '' file; do \
27
- pkg_dir="$(dirname "$file")"; \
28
- pkg_name="$(basename "$pkg_dir")"; \
29
- echo "Copying Titan extension: $pkg_name from $pkg_dir"; \
30
- cp -r "$pkg_dir" "/app/.ext/$pkg_name"; \
31
- done && \
32
- echo "Extensions in .ext:" && \
33
- ls -R /app/.ext
34
-
35
- # Build Titan metadata + bundle JS actions
36
- RUN titan build
37
-
38
- # Build Rust binary
39
- RUN cd server && cargo build --release
40
-
41
-
42
-
43
- # ================================================================
44
- # STAGE 2 — Runtime Image (Lightweight)
45
- # ================================================================
46
- FROM debian:stable-slim
47
-
48
- WORKDIR /app
49
-
50
- # Copy Rust binary from builder stage
51
- COPY --from=builder /app/server/target/release/titan-server ./titan-server
52
-
53
- # Copy Titan routing metadata
54
- COPY --from=builder /app/server/routes.json ./routes.json
55
- COPY --from=builder /app/server/action_map.json ./action_map.json
56
-
57
- # Copy Titan JS bundles
58
- RUN mkdir -p /app/actions
59
- COPY --from=builder /app/server/actions /app/actions
60
-
61
- # Copy only Titan extensions
62
- COPY --from=builder /app/.ext ./.ext
63
-
64
- EXPOSE 3000
65
-
66
- CMD ["./titan-server"]
@@ -1,3 +0,0 @@
1
- node_modules
2
- npm-debug.log
3
- .git
@@ -1,38 +0,0 @@
1
- # Node & Packages
2
- node_modules/
3
- npm-debug.log*
4
- yarn-debug.log*
5
- yarn-error.log*
6
- package-lock.json
7
- yarn.lock
8
-
9
- # Titan Runtime (Auto-generated - DO NOT COMMIT)
10
- titan/server-bin*
11
- .titan/
12
- .ext/
13
- server/routes.json
14
- server/action_map.json
15
- server/actions/
16
- server/titan/
17
- server/src/actions_rust/
18
-
19
- # Rust Build Artifacts
20
- server/target/
21
- Cargo.lock
22
-
23
- # OS Files
24
- .DS_Store
25
- Thumbs.db
26
- *.tmp
27
- *.bak
28
-
29
- # Environment & Secrets
30
- .env
31
- .env.local
32
- .env.*.local
33
-
34
- # IDEs
35
- .vscode/
36
- .idea/
37
- *.swp
38
- *.swo
@@ -1,101 +0,0 @@
1
- export { };
2
-
3
- declare global {
4
- /**
5
- * TITAN TYPE DEFINITIONS
6
- * ----------------------
7
- * These types are globally available in your Titan project.
8
- */
9
-
10
- /**
11
- * The Titan Request Object passed to actions.
12
- */
13
- interface TitanRequest {
14
- body: any;
15
- method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
16
- path: string;
17
- headers: {
18
- host?: string;
19
- "content-type"?: string;
20
- "user-agent"?: string;
21
- authorization?: string;
22
- [key: string]: string | undefined;
23
- };
24
- params: Record<string, string>;
25
- query: Record<string, string>;
26
- }
27
-
28
- interface DbConnection {
29
- /**
30
- * Execute a SQL query.
31
- * @param sql The SQL query string.
32
- * @param params (Optional) Parameters for the query ($1, $2, etc).
33
- */
34
- query(sql: string, params?: any[]): any[];
35
- }
36
-
37
- /**
38
- * Define a Titan Action with type inference.
39
- * @example
40
- * export const hello = defineAction((req) => {
41
- * return req.headers;
42
- * });
43
- */
44
- function defineAction<T>(actionFn: (req: TitanRequest) => T): (req: TitanRequest) => T;
45
-
46
- /**
47
- * Titan Runtime Utilities
48
- */
49
- const t: {
50
- /**
51
- * Log messages to the server console with Titan formatting.
52
- */
53
- log(...args: any[]): void;
54
-
55
- /**
56
- * Read a file contents as string.
57
- * @param path Relative path to the file from project root.
58
- */
59
- read(path: string): string;
60
-
61
- fetch(url: string, options?: {
62
- method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
63
- headers?: Record<string, string>;
64
- body?: string | object;
65
- }): {
66
- ok: boolean;
67
- status?: number;
68
- body?: string;
69
- error?: string;
70
- };
71
-
72
- jwt: {
73
- sign(
74
- payload: object,
75
- secret: string,
76
- options?: { expiresIn?: string | number }
77
- ): string;
78
- verify(token: string, secret: string): any;
79
- };
80
-
81
- password: {
82
- hash(password: string): string;
83
- verify(password: string, hash: string): boolean;
84
- };
85
-
86
- db: {
87
- connect(url: string): DbConnection;
88
- };
89
-
90
- /**
91
- * Titan Validator (Zod-compatible)
92
- */
93
- valid: typeof import("@titanpl/valid");
94
- };
95
-
96
- /**
97
- * Global Request Object
98
- * Available automatically in actions.
99
- */
100
- var req: TitanRequest;
101
- }
@@ -1,66 +0,0 @@
1
- # ================================================================
2
- # STAGE 1 — Build Titan (JS → Rust)
3
- # ================================================================
4
- FROM rust:1.91.1 AS builder
5
-
6
- # Install Node for Titan CLI + bundler
7
- RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
8
- && apt-get install -y nodejs
9
-
10
- # Install Titan CLI (latest)
11
- RUN npm install -g @ezetgalaxy/titan@latest
12
-
13
- WORKDIR /app
14
-
15
- # Copy project files
16
- COPY . .
17
-
18
- # Install JS dependencies (needed for Titan DSL + bundler)
19
- RUN npm install
20
-
21
- SHELL ["/bin/bash", "-c"]
22
-
23
- # Extract Titan extensions into .ext
24
- RUN mkdir -p /app/.ext && \
25
- find /app/node_modules -maxdepth 5 -type f -name "titan.json" -print0 | \
26
- while IFS= read -r -d '' file; do \
27
- pkg_dir="$(dirname "$file")"; \
28
- pkg_name="$(basename "$pkg_dir")"; \
29
- echo "Copying Titan extension: $pkg_name from $pkg_dir"; \
30
- cp -r "$pkg_dir" "/app/.ext/$pkg_name"; \
31
- done && \
32
- echo "Extensions in .ext:" && \
33
- ls -R /app/.ext
34
-
35
- # Build Titan metadata + bundle JS actions
36
- RUN titan build
37
-
38
- # Build Rust binary
39
- RUN cd server && cargo build --release
40
-
41
-
42
-
43
- # ================================================================
44
- # STAGE 2 — Runtime Image (Lightweight)
45
- # ================================================================
46
- FROM debian:stable-slim
47
-
48
- WORKDIR /app
49
-
50
- # Copy Rust binary from builder stage
51
- COPY --from=builder /app/server/target/release/titan-server ./titan-server
52
-
53
- # Copy Titan routing metadata
54
- COPY --from=builder /app/server/routes.json ./routes.json
55
- COPY --from=builder /app/server/action_map.json ./action_map.json
56
-
57
- # Copy Titan JS bundles
58
- RUN mkdir -p /app/actions
59
- COPY --from=builder /app/server/actions /app/actions
60
-
61
- # Copy only Titan extensions
62
- COPY --from=builder /app/.ext ./.ext
63
-
64
- EXPOSE 3000
65
-
66
- CMD ["./titan-server"]
@@ -1,3 +0,0 @@
1
- node_modules
2
- npm-debug.log
3
- .git
@@ -1,38 +0,0 @@
1
- # Node & Packages
2
- node_modules/
3
- npm-debug.log*
4
- yarn-debug.log*
5
- yarn-error.log*
6
- package-lock.json
7
- yarn.lock
8
-
9
- # Titan Runtime (Auto-generated - DO NOT COMMIT)
10
- titan/server-bin*
11
- .titan/
12
- .ext/
13
- server/routes.json
14
- server/action_map.json
15
- server/actions/
16
- server/titan/
17
- server/src/actions_rust/
18
-
19
- # Rust Build Artifacts
20
- server/target/
21
- Cargo.lock
22
-
23
- # OS Files
24
- .DS_Store
25
- Thumbs.db
26
- *.tmp
27
- *.bak
28
-
29
- # Environment & Secrets
30
- .env
31
- .env.local
32
- .env.*.local
33
-
34
- # IDEs
35
- .vscode/
36
- .idea/
37
- *.swp
38
- *.swo
@@ -1,102 +0,0 @@
1
- /**
2
- * TITAN TYPE DEFINITIONS
3
- */
4
-
5
- /**
6
- * The Titan Request Object passed to actions.
7
- */
8
- interface TitanRequest {
9
- body: any;
10
- method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
11
- path: string;
12
- headers: {
13
- host?: string;
14
- "content-type"?: string;
15
- "user-agent"?: string;
16
- authorization?: string;
17
- [key: string]: string | undefined;
18
- };
19
- params: Record<string, string>;
20
- query: Record<string, string>;
21
- }
22
-
23
- interface DbConnection {
24
- /**
25
- * Execute a SQL query.
26
- * @param sql The SQL query string.
27
- * @param params (Optional) Parameters for the query ($1, $2, etc).
28
- */
29
- query(sql: string, params?: any[]): any[];
30
- }
31
-
32
- /**
33
- * Define a Titan Action with type inference.
34
- * @example
35
- * export const hello = defineAction((req) => {
36
- * return req.headers;
37
- * });
38
- */
39
- declare function defineAction<T>(actionFn: (req: TitanRequest) => T): (req: TitanRequest) => T;
40
-
41
- /**
42
- * Titan Runtime Utilities
43
- */
44
- declare const t: {
45
- /**
46
- * Log messages to the server console with Titan formatting.
47
- */
48
- log(...args: any[]): void;
49
-
50
- /**
51
- * Read a file contents as string.
52
- * @param path Relative path to the file from project root.
53
- */
54
- read(path: string): string;
55
-
56
- fetch(url: string, options?: {
57
- method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
58
- headers?: Record<string, string>;
59
- body?: string | object;
60
- }): {
61
- ok: boolean;
62
- status?: number;
63
- body?: string;
64
- error?: string;
65
- };
66
-
67
- jwt: {
68
- sign(
69
- payload: object,
70
- secret: string,
71
- options?: { expiresIn?: string | number }
72
- ): string;
73
- verify(token: string, secret: string): any;
74
- };
75
-
76
- password: {
77
- hash(password: string): string;
78
- verify(password: string, hash: string): boolean;
79
- };
80
-
81
- db: {
82
- connect(url: string): DbConnection;
83
- };
84
- };
85
-
86
- // Declaring module for import t from "../titan/titan.js"
87
- declare module "*titan.js" {
88
- export interface RouteHandler {
89
- reply(value: any): void;
90
- action(name: string): void;
91
- }
92
-
93
- export interface Titan {
94
- get(route: string): RouteHandler;
95
- post(route: string): RouteHandler;
96
- log(module: string, msg: string): void;
97
- start(port?: number, msg?: string): Promise<void>;
98
- }
99
-
100
- const t: Titan;
101
- export default t;
102
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes