@@ -7,78 +7,66 @@ import { BasicAuth, tgDeploy } from "@typegraph/sdk/tg_deploy.js";
7
7
import { wit_utils } from "@typegraph/sdk/wit.js" ;
8
8
import * as path from "path" ;
9
9
10
-
11
- // deno
12
- // import { Policy, t, typegraph } from "../../typegraph/node/sdk/dist/index.js";
13
- // import { DenoRuntime } from "../../typegraph/node/sdk/dist/runtimes/deno.js";
14
- // import { PythonRuntime } from "../../typegraph/node/sdk/dist/runtimes/python.js";
15
- // import { WasmEdgeRuntime } from "../../typegraph/node/sdk/dist/runtimes/wasmedge.js";
16
- // import { tgDeploy } from "../../typegraph/node/sdk/dist/tg_deploy.js";
17
- // import { PrismaRuntime } from "../../typegraph/node/sdk/dist/providers/prisma.js";
18
- // import { BasicAuth } from "../../typegraph/node/sdk/dist/tg_deploy.js";
19
- // import { wit_utils } from "../../typegraph/node/sdk/dist/wit.js";
20
-
21
10
const tg = await typegraph ( {
22
11
name : "deploy-example-node" ,
23
12
} , ( g ) => {
24
- const deno = new DenoRuntime ( ) ;
25
- const python = new PythonRuntime ( ) ;
26
- const wasmedge = new WasmEdgeRuntime ( ) ;
27
- const prisma = new PrismaRuntime ( "prisma" , "POSTGRES" )
28
- const pub = Policy . public ( ) ;
29
- const student = t . struct (
30
- {
31
- id : t . integer ( { } , { asId : true } ) ,
32
- name : t . string ( ) ,
33
- } ,
34
- { name : "Student" } ,
35
- ) ;
36
-
37
- g . expose ( {
38
- test : deno . static ( t . struct ( { a : t . string ( ) } ) , { a : "HELLO" } ) ,
39
- // Deno
40
- sayHello : deno . import (
41
- t . struct ( { name : t . string ( ) } ) ,
42
- t . string ( ) ,
43
- { module : "scripts/deno/say_hello.ts" , name : "sayHello" }
44
- ) ,
45
- sayHelloLambda : deno . func (
46
- t . struct ( { name : t . string ( ) } ) ,
47
- t . string ( ) ,
48
- { code : "({ name }) => `Hello ${name} from deno lambda`" }
49
- ) ,
50
- // Python
51
- sayHelloPyLambda : python . fromLambda (
52
- t . struct ( { name : t . string ( ) } ) ,
53
- t . string ( ) ,
54
- { code : `lambda obj: f"Hello {obj['name']} from python lambda"` }
55
- ) ,
56
- sayHelloPyMod : python . import (
57
- t . struct ( { name : t . string ( ) } ) ,
58
- t . string ( ) ,
59
- { module : "scripts/python/say_hello.py" , name : "sayHello" }
60
- ) ,
61
- // Wasmedge
62
- testWasmedge : wasmedge . wasi (
63
- t . struct ( { "a" : t . float ( ) , "b" : t . float ( ) } ) ,
64
- t . integer ( ) ,
65
- { wasm : "wasi/rust.wasm" , func : "add" }
66
- ) ,
67
- // Prisma
68
- createStudent : prisma . create ( student ) ,
69
- findManyStudent : prisma . findMany ( student ) ,
70
- } , pub ) ;
71
- } ,
72
- ) ;
13
+ const deno = new DenoRuntime ( ) ;
14
+ const python = new PythonRuntime ( ) ;
15
+ const wasmedge = new WasmEdgeRuntime ( ) ;
16
+ const prisma = new PrismaRuntime ( "prisma" , "POSTGRES" ) ;
17
+ const pub = Policy . public ( ) ;
18
+ const student = t . struct (
19
+ {
20
+ id : t . integer ( { } , { asId : true } ) ,
21
+ name : t . string ( ) ,
22
+ } ,
23
+ { name : "Student" } ,
24
+ ) ;
25
+
26
+ g . expose ( {
27
+ test : deno . static ( t . struct ( { a : t . string ( ) } ) , { a : "HELLO" } ) ,
28
+ // Deno
29
+ sayHello : deno . import (
30
+ t . struct ( { name : t . string ( ) } ) ,
31
+ t . string ( ) ,
32
+ { module : "scripts/deno/say_hello.ts" , name : "sayHello" } ,
33
+ ) ,
34
+ sayHelloLambda : deno . func (
35
+ t . struct ( { name : t . string ( ) } ) ,
36
+ t . string ( ) ,
37
+ { code : "({ name }) => `Hello ${name} from deno lambda`" } ,
38
+ ) ,
39
+ // Python
40
+ sayHelloPyLambda : python . fromLambda (
41
+ t . struct ( { name : t . string ( ) } ) ,
42
+ t . string ( ) ,
43
+ { code : `lambda obj: f"Hello {obj['name']} from python lambda"` } ,
44
+ ) ,
45
+ sayHelloPyMod : python . import (
46
+ t . struct ( { name : t . string ( ) } ) ,
47
+ t . string ( ) ,
48
+ { module : "scripts/python/say_hello.py" , name : "sayHello" } ,
49
+ ) ,
50
+ // Wasmedge
51
+ testWasmedge : wasmedge . wasi (
52
+ t . struct ( { "a" : t . float ( ) , "b" : t . float ( ) } ) ,
53
+ t . integer ( ) ,
54
+ { wasm : "wasi/rust.wasm" , func : "add" } ,
55
+ ) ,
56
+ // Prisma
57
+ createStudent : prisma . create ( student ) ,
58
+ findManyStudent : prisma . findMany ( student ) ,
59
+ } , pub ) ;
60
+ } ) ;
73
61
74
62
const artifactsConfig = {
75
63
prismaMigration : {
76
64
globalAction : {
77
65
create : true ,
78
- reset : true
66
+ reset : true ,
79
67
} ,
80
- migrationDir : path . join ( "prisma-migrations" , tg . name )
81
- }
68
+ migrationDir : path . join ( "prisma-migrations" , tg . name ) ,
69
+ } ,
82
70
} ;
83
71
const baseUrl = "http://localhost:7890" ;
84
72
const auth = new BasicAuth ( "admin" , "password" ) ;
@@ -87,7 +75,7 @@ tgDeploy(tg, {
87
75
baseUrl,
88
76
auth,
89
77
secrets : {
90
- TG_DEPLOY_EXAMPLE_NODE_POSTGRES : "postgresql://postgres:password@localhost:5432/db?schema=e2e7894"
78
+ POSTGRES : "postgresql://postgres:password@localhost:5432/db?schema=e2e7894" ,
91
79
} ,
92
80
artifactsConfig : {
93
81
...artifactsConfig ,
@@ -106,11 +94,11 @@ tgDeploy(tg, {
106
94
const baseDir = artifactsConfig . prismaMigration . migrationDir ;
107
95
// cwd + tg_name + runtime_name
108
96
const fullPath = path . join ( baseDir , runtime ) ;
109
- wit_utils . unpackTarb64 ( migrations , fullPath ) ;
110
- console . log ( `Unpacked migrations at ${ fullPath } ` )
97
+ wit_utils . unpackTarb64 ( migrations , fullPath ) ;
98
+ console . log ( `Unpacked migrations at ${ fullPath } ` ) ;
111
99
} ) ;
112
100
} else {
113
101
throw new Error ( JSON . stringify ( typegate ) ) ;
114
102
}
115
- } )
103
+ } )
116
104
. catch ( console . error ) ;
0 commit comments