Add a deno fresh plugin restdb to inject REST API routes (prescribe a simple document database of collections grouping records by ID, so that it remainsRESTful). Refer to the generateFreshHandlers from denoland/kv_api for how this should be implemented. In summary, the plugin should dynamically generate fresh the fresh handler based on the config object paths (containing e.g. a list of resources and its available methods), the plugin should then inject them under a configurable prefix.
Implementation
The RestdbOptions should provide sensible defaults (zero-config by default) but allow overriding for each service. Also, if should be possible to provide common configurations at root e.g. idField, but overwrite it per service if necessary. A schema field should be provided for built-in zod/valibot validation.
Add a deno fresh plugin
restdb
to inject REST API routes (prescribe a simple document database of collections grouping records by ID, so that it remainsRESTful). Refer to thegenerateFreshHandlers
from denoland/kv_api for how this should be implemented. In summary, the plugin should dynamically generate fresh the fresh handler based on the config object paths (containing e.g. a list of resources and its available methods), the plugin should then inject them under a configurable prefix.Implementation
The
RestdbOptions
should provide sensible defaults (zero-config by default) but allow overriding for each service. Also, if should be possible to provide common configurations at root e.g.idField
, but overwrite it per service if necessary. Aschema
field should be provided for built-inzod
/valibot
validation.Route overview
The plugin should be able to handle both patterns (KV and REST) simoultaneously. The following routes would allow that:
REST operations
/kv/:resource
/kv/:resource/:id
/kv/:resource
/kv/:resource/:id
/kv/:resource/:id
/kv/:resource/:id
KV operations
/kv?op=list
/kv
/kv
/kv
/kv?op=sum
/kv?op=min
/kv?op=max
See also kv_toolbox for common utilities and anywhichway/denodata which might be useful.