libflitter/templates/router.js

  1. /**
  2. * @module libflitter/templates/router
  3. */
  4. /**
  5. * Get the contents of a new router definition file with the specified object name.
  6. * @param {string} name - the name of the router definition object
  7. * @returns {string}
  8. */
  9. module.exports = exports = (name) => {
  10. return `/*
  11. * ${name} Routes
  12. * -------------------------------------------------------------
  13. * Put some description here!
  14. */
  15. const ${name} = {
  16. /*
  17. * Define the prefix applied to each of these routes.
  18. * For example, if prefix is '/auth':
  19. * '/' becomes '/auth'
  20. * '/login' becomes '/auth/login'
  21. */
  22. prefix: '/${name.toLowerCase()}',
  23. /*
  24. * Define middleware that should be applied to all
  25. * routes defined in this file. Middleware should be
  26. * included using Flitter's global mw() function, but
  27. * it can also be added directly using require().
  28. */
  29. middleware: [
  30. // 'Middleware Name',
  31. ],
  32. /*
  33. * Define GET routes.
  34. * These routes are registered as GET methods.
  35. * Handlers for these routes should be specified as
  36. * an array of functions that are applied in order.
  37. *
  38. * You should refer to middleware and controller methods
  39. * by their fully-qualified canonical names. For example:
  40. *
  41. * controller::auth:Forms.login_get
  42. * middleware::auth:UserOnly
  43. */
  44. get: {
  45. // '/': ['controller::Controller_Name.handler_name'],
  46. },
  47. /*
  48. * Define POST routes.
  49. * These routes are registered as POST methods.
  50. * Handlers for these routes should be specified as
  51. * an array of functions that are applied in order.
  52. *
  53. * mw() calls apply Flitter middleware
  54. * controller() calls get methods in Flitter controllers
  55. */
  56. post: {
  57. },
  58. // Supports get, post, patch, put, delete, &c.
  59. }
  60. module.exports = exports = ${name}`
  61. }
JAVASCRIPT
Copied!