askql
askql copied to clipboard
Introduce a mechanism for adding third-party AskVM resources
Some of the resources on AskVM are built-in (like if, call or query), some of them are defined in source code running the server, but there is no good way to add third-party packages of resources without modifying the existing source code.
Resources like:
- database access
- Facebook / GitHub / any other service API client
- payment providers
- etc.
What kind of solution would you suggest? Ideas from all readers are welcome :)
@czerwinskilukasz1 here's how you can add a third-party AskVM resource:
const askql = require("askql");
const { resource } = askql.askvm;
(async () => {
const result = await askql.runUntyped(
{
resources: {
...askql.askvm.resources,
env: resource({
resolver() {
return process.env;
},
}),
},
},
askql.parse("ask { env:at('PATH') }")
);
console.log(JSON.stringify(result, null, 2));
})();
I have just tested it with the production version 1.0.2