You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create Command File: Add a new file src/cli/commands/call.ts.
import{Command}from"../deps.ts";import{GlobalOpts,initProject}from"../common.ts";import{handleRequest}from"../../runtime/server.ts";exportconstcallCommand=newCommand<GlobalOpts>().description("Call a script").arguments("<module> <script> <body>").action(async(opts,module,script,body)=>{constproject=awaitinitProject(opts);constreq=newRequest("http://localhost/modules/"+module+"/scripts/"+script+"/call",{method: "POST",headers: {"Content-Type": "application/json"},body: JSON.stringify(JSON.parse(body)),});constinfo={remoteAddress: "127.0.0.1"};constresponse=awaithandleRequest(project.runtime,req,info);console.log(awaitresponse.json());});
Register Command: Update src/cli/main.ts to include the new command.
import{callCommand}from"./commands/call.ts";// Add to the CLI toolconstcli=newCommand().name("opengb").version("0.1.0").description("OpenGB CLI tool").command("call",callCommand);awaitcli.parse(Deno.args);
Motivation
There's no easy way to manually call scripts. Should allow doing this via the CLI.
Implementation
TBD how we pass the body to the request.
Alternatives
Auto-generate SDK and create Deno REPL with access to the SDK. This allows using native JS to call the functions with type safety.
The text was updated successfully, but these errors were encountered: