Guest User

Untitled

a guest
Jan 15th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. const Ottis = require('../lib');
  2. const router = Ottis.router;
  3.  
  4. const auth = Ottis({
  5. users: [
  6. "admin",
  7. "customer"
  8. ]
  9. });
  10.  
  11. /* Admin Config */
  12. auth .addConfigFor('admin')
  13. .forResource('customers')({
  14. config: [router().all()]
  15. })
  16. .forResource('anonymous-customers')({
  17. config: [router().all()]
  18. })
  19. .forResource('products')({
  20. config: [
  21. router("/").get().post().done(),
  22. router("/:id").get().put().delete().done(),
  23. router("/:id/location/:name").get().done()
  24. ]
  25. })
  26.  
  27.  
  28. /* Customer Config */
  29. auth.addConfigFor('customer')
  30. .forResource('customers')({
  31. config: [
  32. router("/me").get().put().delete().done()
  33. ]
  34. })
  35. .forResource('anonymous-customers')({
  36. config: [
  37. router("/:id").get().done()
  38. ]
  39. })
  40. .forResource('products')({
  41. config: [
  42. router("/").get().done(),
  43. router("/:id").get().done(),
  44. ]
  45. })
  46.  
  47. module.exports = auth.User;
Add Comment
Please, Sign In to add comment