Skip to content

Latest commit

 

History

History

kv-todos

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Example: Todos KV

Note No playground link because this example relies on a KV Namespace.

Defines a /users/:username/todo resource controller, storing all records inside a KV namespace:

  • GET /users/:username/todos – lists all Todo records for the :username owner
  • POST /users/:username/todos – creates a new Todo record for the :username owner
  • GET /users/:username/todos/:uid – retrieves a single Todo record, identified by the :username:::uid pairing
  • PUT /users/:username/todos/:uid – updates a Todo record with new values, identified by the :username:::uid pairing
  • DELETE /users/:username/todos/:uid – deletes a Todo record, identified by the :username:::uid pairing

Important: This is for demonstration purposes only! In order to be production-ready, it needs:

  • Authentication / Authorization
    Currently, any :username value is accepted... and by anybody.
  • Proper input validation
    Currently, only the input.title value is checked for a truthy-ness.
  • Stricter uid rules / route validation
    Ideally you'd validate route-params like uid to protect against unnecessary KV interactions.

License

MIT