Update script readme (#1930)

* Update script readme

* Types better added
This commit is contained in:
Henri Courdent
2023-07-25 09:35:40 +02:00
committed by GitHub
parent 6a2c2394c5
commit d99709ae70
+16 -8
View File
@@ -96,20 +96,28 @@ You can build your entire infra on top of Windmill!
## Show me some actual script code
```typescript
import * as wmill from "https://deno.land/x/windmill@v1.62.0/mod.ts";
//import any dependency from npm
import * as wmill from "https://deno.land/x/windmill@v1.136.0/mod.ts"
import cowsay from "npm:cowsay@1.5.0";
// fill the type, or use the +Resource type to get a type-safe reference to a resource
type Postgresql = {
host: string,
port: number,
user: string,
dbname: string,
sslmode: string,
password: string
}
export async function main(
a: number,
// unions generate enums
b: "my" | "enum",
// default parameters prefill the field
d = "default arg",
// nested objects work c = { nested: "object" },
// permissioned and typed json
db: wmill.Resource<"postgresql">
c: Postgresql,
d = "inferred type string from default arg",
e = { nested: "object" },
//f: wmill.Base64
) {
const email = Deno.env.get("WM_EMAIL");
// variables are permissioned and by path