Awesome
DVM Reference Implementation
This is a reference implementation of a DVM (Data Vending Machine) backend.
Properties
- Segregated identities per DVM
- Modular DVMs -- each DVM is instantiated in it's own module
Modules
DVMs are just modules that export a register
function. This function is called
upon instantiation of the DVM.
Within the module, the DVM should register handlers for the different kinds it wants to support.
Here is a demo DVM that would say Hello World when it's tagged in a request
// config.json
{
"dvms": {
"You might have missed": {
"module": "dvms/hello-world.js",
"key": "<private-key-in-hex>",
"requireTagging": true,
"kinds": {
"65100": {
}
}
}
}
}
// hello-world.ts
export async function register(dvm: DVM): Promise<void> {
dvm.d("registering DVM", dvm.name);
const sayHello = async (request: NDKDVMRequestExtended) => {
request.processing(`I am processing your request job`);
const response = new NDKDVMJobResult();
response.content = "Hello World!";
return response;
};
dvm.handlers[65100].push(sayHello);
}
Author
License
MIT