You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
822 B

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. const data = [
  2. { id: 1, name: 'Conifer', maxHeight: 115 },
  3. { id: 2, name: 'Eucalyptus', maxHeight: 210 },
  4. { id: 3, name: 'Ash', maxHeight: 40 },
  5. { id: 4, name: 'Elder', maxHeight: 5 },
  6. { id: 5, name: 'Holly', maxHeight: 10 }
  7. ]
  8. module.exports = [
  9. /* CREATE */
  10. {
  11. request: { method: 'POST' },
  12. response: {
  13. status: 201,
  14. location: '/tree/1'
  15. }
  16. },
  17. /* READ */
  18. {
  19. request: { method: 'GET' },
  20. response: {
  21. status: 200,
  22. body: function (ctx) {
  23. return data.filter(tree => tree.maxHeight > Number(ctx.query.tallerThan))
  24. }
  25. }
  26. },
  27. /* UPDATE (forbidden on collection)*/
  28. {
  29. request: { method: 'PUT' },
  30. response: { status: 404 }
  31. },
  32. /* DELETE (forbidden on collection) */
  33. {
  34. request: { method: 'DELETE' },
  35. response: { status: 404 }
  36. }
  37. ]