Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pablof7z/dvm-references
reference implementation of a DVM (Data Vending Machine) backend
https://github.com/pablof7z/dvm-references
Last synced: 2 months ago
JSON representation
reference implementation of a DVM (Data Vending Machine) backend
- Host: GitHub
- URL: https://github.com/pablof7z/dvm-references
- Owner: pablof7z
- Created: 2023-08-31T11:53:07.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-05-16T14:01:09.000Z (7 months ago)
- Last Synced: 2024-05-16T15:26:49.607Z (7 months ago)
- Language: TypeScript
- Size: 209 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-nostr - dvm references - references.svg?style=social) - reference implementation of a DVM (Data Vending Machine) backend (NIP-90 Data vending machines / Client reviews and/or comparisons)
README
# DVM Reference Implementation
This is a reference implementation of a DVM (Data Vending Machine) backend.
## Properties
- [x] Segregated identities per DVM
- [x] 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
```json
// config.json
{
"dvms": {
"You might have missed": {
"module": "dvms/hello-world.js",
"key": "",
"requireTagging": true,
"kinds": {
"65100": {
}
}
}
}
}
``````typescript
// hello-world.ts
export async function register(dvm: DVM): Promise {
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
* [@pablof7z](https://nostr.com/npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft)
## License
MIT