From d99709ae70e19c13098f72e2ece18161cb6bc9e7 Mon Sep 17 00:00:00 2001 From: Henri Courdent <122811744+hcourdent@users.noreply.github.com> Date: Tue, 25 Jul 2023 09:35:40 +0200 Subject: [PATCH] Update script readme (#1930) * Update script readme * Types better added --- README.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 769e2bb151..fa52e3ef19 100644 --- a/README.md +++ b/README.md @@ -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