Last active 1730175957

Revision a4cab4763697ea20e1ba4f97378f32dc4122aeec

Windmill-1.ts Raw
1//import any dependency from npm
2import * as wmill from "windmill-client"
3import * 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
6type Postgresql = {
7 host: string;
8 port: number;
9 user: string;
10 dbname: string;
11 sslmode: string;
12 password: string;
13};
14
15export 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}