@ezetgalaxy/titan 26.7.5 → 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 +86 -200
- package/index.js +87 -23
- package/package.json +4 -3
- package/templates/js/_gitignore +37 -0
- package/templates/{package.json → js/package.json} +3 -0
- package/templates/{server → js/server}/actions/hello.jsbundle +4 -1
- 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/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/templates/_gitignore +0 -25
- 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}/action_map.json +0 -0
- /package/templates/{server → js/server}/routes.json +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
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "esnext",
|
|
4
|
+
"target": "esnext",
|
|
5
|
+
"checkJs": false,
|
|
6
|
+
"noImplicitAny": false,
|
|
7
|
+
"allowJs": true,
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"baseUrl": ".",
|
|
10
|
+
"paths": {
|
|
11
|
+
"*": [
|
|
12
|
+
"./app/*"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"include": [
|
|
17
|
+
"app/**/*"
|
|
18
|
+
]
|
|
19
|
+
}
|