knox ревизий этого фрагмента . К ревизии
1 file changed, 33 insertions
Windmill-1.ts(файл создан)
@@ -0,0 +1,33 @@ | |||
1 | + | //import any dependency from npm | |
2 | + | import * as wmill from "windmill-client" | |
3 | + | import * as cowsay from 'cowsay@1.5.0'; | |
4 | + | ||
5 | + | // fill the type, or use the +Resource type to get a type-safe reference to a resource | |
6 | + | type Postgresql = { | |
7 | + | host: string; | |
8 | + | port: number; | |
9 | + | user: string; | |
10 | + | dbname: string; | |
11 | + | sslmode: string; | |
12 | + | password: string; | |
13 | + | }; | |
14 | + | ||
15 | + | export async function main( | |
16 | + | a: number, | |
17 | + | b: "my" | "enum", | |
18 | + | c: Postgresql, | |
19 | + | d = "inferred type string from default arg", | |
20 | + | e = { nested: "object" } | |
21 | + | //f: wmill.Base64 | |
22 | + | ) { | |
23 | + | const email = process.env["WM_EMAIL"]; | |
24 | + | // variables are permissioned and by path | |
25 | + | let variable = await wmill.getVariable("f/company-folder/my_secret"); | |
26 | + | const lastTimeRun = await wmill.getState(); | |
27 | + | // logs are printed and always inspectable | |
28 | + | console.log(cowsay.say({ text: "hello " + email + " " + lastTimeRun })); | |
29 | + | await wmill.setState(Date.now()); | |
30 | + | ||
31 | + | // return is serialized as JSON | |
32 | + | return { foo: d, variable }; | |
33 | + | } |
Новее
Позже