@ezetgalaxy/titan 26.8.3 → 26.9.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 +63 -14
- package/index.js +62 -15
- package/package.json +1 -1
- package/templates/extension/README.md +104 -104
- package/templates/extension/index.js +27 -27
- package/templates/extension/jsconfig.json +12 -12
- package/templates/extension/native/Cargo.toml +9 -9
- package/templates/extension/native/src/lib.rs +5 -5
- package/templates/extension/package.json +20 -20
- package/templates/extension/titan.json +17 -17
- package/templates/js/Dockerfile +66 -66
- package/templates/js/_dockerignore +3 -3
- package/templates/js/_gitignore +1 -0
- package/templates/js/app/actions/hello.js +5 -5
- package/templates/js/app/titan.d.ts +87 -87
- package/templates/js/jsconfig.json +18 -18
- package/templates/js/server/src/action_management.rs +131 -131
- package/templates/js/server/src/errors.rs +10 -10
- package/templates/js/server/src/extensions.rs +989 -989
- package/templates/js/server/src/utils.rs +33 -33
- package/templates/js/titan/bundle.js +78 -78
- package/templates/js/titan/dev.js +9 -1
- package/templates/js/titan/titan.js +122 -122
- package/templates/rust/Dockerfile +66 -66
- package/templates/rust/_dockerignore +3 -3
- package/templates/rust/_gitignore +1 -0
- package/templates/rust/app/actions/hello.js +5 -5
- package/templates/rust/app/actions/rust_hello.rs +14 -14
- package/templates/rust/app/titan.d.ts +101 -101
- package/templates/rust/jsconfig.json +18 -18
- package/templates/rust/server/src/action_management.rs +131 -131
- package/templates/rust/server/src/errors.rs +10 -10
- package/templates/rust/server/src/extensions.rs +989 -989
- package/templates/rust/server/src/utils.rs +33 -33
- package/templates/rust/titan/dev.js +9 -1
- package/templates/rust-ts/Dockerfile +66 -0
- package/templates/rust-ts/_dockerignore +3 -0
- package/templates/rust-ts/_gitignore +38 -0
- package/templates/rust-ts/app/actions/hello.ts +5 -0
- package/templates/rust-ts/app/actions/rust_hello.rs +14 -0
- package/templates/rust-ts/app/app.ts +11 -0
- package/templates/rust-ts/app/titan.d.ts +101 -0
- package/templates/rust-ts/package.json +14 -0
- package/templates/rust-ts/server/Cargo.lock +2869 -0
- package/templates/rust-ts/server/Cargo.toml +39 -0
- package/templates/rust-ts/server/src/action_management.rs +131 -0
- package/templates/rust-ts/server/src/errors.rs +51 -0
- package/templates/rust-ts/server/src/extensions.rs +989 -0
- package/templates/rust-ts/server/src/main.rs +468 -0
- package/templates/rust-ts/server/src/utils.rs +33 -0
- package/templates/rust-ts/titan/bundle.js +157 -0
- package/templates/rust-ts/titan/dev.js +402 -0
- package/templates/rust-ts/titan/titan.js +122 -0
- package/templates/rust-ts/tsconfig.json +21 -0
- package/templates/ts/Dockerfile +66 -0
- package/templates/ts/_dockerignore +3 -0
- package/templates/ts/_gitignore +38 -0
- package/templates/ts/app/actions/hello.ts +9 -0
- package/templates/ts/app/app.ts +10 -0
- package/templates/ts/app/titan.d.ts +102 -0
- package/templates/ts/package.json +26 -0
- package/templates/ts/server/Cargo.lock +2869 -0
- package/templates/ts/server/Cargo.toml +27 -0
- package/templates/ts/server/src/action_management.rs +131 -0
- package/templates/ts/server/src/errors.rs +51 -0
- package/templates/ts/server/src/extensions.rs +989 -0
- package/templates/ts/server/src/main.rs +437 -0
- package/templates/ts/server/src/utils.rs +33 -0
- package/templates/ts/titan/bundle.js +78 -0
- package/templates/ts/titan/dev.js +402 -0
- package/templates/ts/titan/titan.js +122 -0
- package/templates/ts/tsconfig.json +16 -0
- package/titanpl-sdk/README.md +109 -109
- package/titanpl-sdk/bin/run.js +254 -254
- package/titanpl-sdk/index.d.ts +46 -46
- package/titanpl-sdk/index.js +5 -5
- package/titanpl-sdk/package.json +32 -32
- package/titanpl-sdk/templates/.dockerignore +3 -3
- package/titanpl-sdk/templates/Dockerfile +53 -53
- package/titanpl-sdk/templates/app/actions/hello.js +5 -5
- package/titanpl-sdk/templates/app/titan.d.ts +87 -87
- package/titanpl-sdk/templates/jsconfig.json +18 -18
- package/titanpl-sdk/templates/server/src/action_management.rs +131 -131
- package/titanpl-sdk/templates/server/src/errors.rs +10 -10
- package/titanpl-sdk/templates/server/src/extensions.rs +640 -640
- package/titanpl-sdk/templates/server/src/utils.rs +33 -33
- package/titanpl-sdk/templates/titan/bundle.js +65 -65
- package/titanpl-sdk/templates/titan/dev.js +113 -113
- package/titanpl-sdk/templates/titan/titan.js +98 -98
- package/templates/js/server/action_map.json +0 -3
- package/templates/js/server/actions/hello.jsbundle +0 -48
- package/templates/js/server/routes.json +0 -16
- package/templates/rust/server/action_map.json +0 -3
- package/templates/rust/server/actions/hello.jsbundle +0 -47
- package/templates/rust/server/routes.json +0 -22
- package/templates/rust/server/src/actions_rust/mod.rs +0 -19
- package/templates/rust/server/src/actions_rust/rust_hello.rs +0 -14
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "titanpl",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A Titan Planet server (TypeScript)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"titan": {
|
|
7
|
+
"template": "ts"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"chokidar": "^5.0.0",
|
|
11
|
+
"esbuild": "^0.27.2",
|
|
12
|
+
"typescript": "^5.0.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@vitest/coverage-v8": "^3.0.0",
|
|
16
|
+
"@vitest/ui": "^3.0.0",
|
|
17
|
+
"vitest": "^3.0.0"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:watch": "vitest",
|
|
22
|
+
"test:coverage": "vitest run --coverage",
|
|
23
|
+
"test:ui": "vitest --ui",
|
|
24
|
+
"typecheck": "tsc --noEmit"
|
|
25
|
+
}
|
|
26
|
+
}
|