blueprints.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**
  2. * Blueprint API Configuration
  3. * (sails.config.blueprints)
  4. *
  5. * These settings are for the global configuration of blueprint routes and
  6. * request options (which impact the behavior of blueprint actions).
  7. *
  8. * You may also override any of these settings on a per-controller basis
  9. * by defining a '_config' key in your controller defintion, and assigning it
  10. * a configuration object with overrides for the settings in this file.
  11. * A lot of the configuration options below affect so-called "CRUD methods",
  12. * or your controllers' `find`, `create`, `update`, and `destroy` actions.
  13. *
  14. * It's important to realize that, even if you haven't defined these yourself, as long as
  15. * a model exists with the same name as the controller, Sails will respond with built-in CRUD
  16. * logic in the form of a JSON API, including support for sort, pagination, and filtering.
  17. *
  18. * For more information on the blueprint API, check out:
  19. * http://sailsjs.org/#/documentation/reference/blueprint-api
  20. *
  21. * For more information on the settings in this file, see:
  22. * http://sailsjs.org/#/documentation/reference/sails.config/sails.config.blueprints.html
  23. *
  24. */
  25. module.exports.blueprints = {
  26. /***************************************************************************
  27. * *
  28. * Action routes speed up the backend development workflow by *
  29. * eliminating the need to manually bind routes. When enabled, GET, POST, *
  30. * PUT, and DELETE routes will be generated for every one of a controller's *
  31. * actions. *
  32. * *
  33. * If an `index` action exists, additional naked routes will be created for *
  34. * it. Finally, all `actions` blueprints support an optional path *
  35. * parameter, `id`, for convenience. *
  36. * *
  37. * `actions` are enabled by default, and can be OK for production-- *
  38. * however, if you'd like to continue to use controller/action autorouting *
  39. * in a production deployment, you must take great care not to *
  40. * inadvertently expose unsafe/unintentional controller logic to GET *
  41. * requests. *
  42. * *
  43. ***************************************************************************/
  44. // actions: true,
  45. /***************************************************************************
  46. * *
  47. * RESTful routes (`sails.config.blueprints.rest`) *
  48. * *
  49. * REST blueprints are the automatically generated routes Sails uses to *
  50. * expose a conventional REST API on top of a controller's `find`, *
  51. * `create`, `update`, and `destroy` actions. *
  52. * *
  53. * For example, a BoatController with `rest` enabled generates the *
  54. * following routes: *
  55. * ::::::::::::::::::::::::::::::::::::::::::::::::::::::: *
  56. * GET /boat -> BoatController.find *
  57. * GET /boat/:id -> BoatController.findOne *
  58. * POST /boat -> BoatController.create *
  59. * PUT /boat/:id -> BoatController.update *
  60. * DELETE /boat/:id -> BoatController.destroy *
  61. * *
  62. * `rest` blueprint routes are enabled by default, and are suitable for use *
  63. * in a production scenario, as long you take standard security precautions *
  64. * (combine w/ policies, etc.) *
  65. * *
  66. ***************************************************************************/
  67. // rest: true,
  68. /***************************************************************************
  69. * *
  70. * Shortcut routes are simple helpers to provide access to a *
  71. * controller's CRUD methods from your browser's URL bar. When enabled, *
  72. * GET, POST, PUT, and DELETE routes will be generated for the *
  73. * controller's`find`, `create`, `update`, and `destroy` actions. *
  74. * *
  75. * `shortcuts` are enabled by default, but should be disabled in *
  76. * production. *
  77. * *
  78. ***************************************************************************/
  79. // shortcuts: true,
  80. /***************************************************************************
  81. * *
  82. * An optional mount path for all blueprint routes on a controller, *
  83. * including `rest`, `actions`, and `shortcuts`. This allows you to take *
  84. * advantage of blueprint routing, even if you need to namespace your API *
  85. * methods. *
  86. * *
  87. * (NOTE: This only applies to blueprint autoroutes, not manual routes from *
  88. * `sails.config.routes`) *
  89. * *
  90. ***************************************************************************/
  91. // prefix: '',
  92. /***************************************************************************
  93. * *
  94. * Whether to pluralize controller names in blueprint routes. *
  95. * *
  96. * (NOTE: This only applies to blueprint autoroutes, not manual routes from *
  97. * `sails.config.routes`) *
  98. * *
  99. * For example, REST blueprints for `FooController` with `pluralize` *
  100. * enabled: *
  101. * GET /foos/:id? *
  102. * POST /foos *
  103. * PUT /foos/:id? *
  104. * DELETE /foos/:id? *
  105. * *
  106. ***************************************************************************/
  107. // pluralize: false,
  108. /***************************************************************************
  109. * *
  110. * Whether the blueprint controllers should populate model fetches with *
  111. * data from other models which are linked by associations *
  112. * *
  113. * If you have a lot of data in one-to-many associations, leaving this on *
  114. * may result in very heavy api calls *
  115. * *
  116. ***************************************************************************/
  117. // populate: true,
  118. /****************************************************************************
  119. * *
  120. * Whether to run Model.watch() in the find and findOne blueprint actions. *
  121. * Can be overridden on a per-model basis. *
  122. * *
  123. ****************************************************************************/
  124. // autoWatch: true,
  125. /****************************************************************************
  126. * *
  127. * The default number of records to show in the response from a "find" *
  128. * action. Doubles as the default size of populated arrays if populate is *
  129. * true. *
  130. * *
  131. ****************************************************************************/
  132. // defaultLimit: 30
  133. };