api.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php
  2. return [
  3. // 默认记录数
  4. 'per_page'=>env('PER_PAGE', '20'),
  5. // 默认显示几天
  6. 'show_time_day_num'=>env('SHOW_TIME_DAY_NUM', '3'),
  7. //默认website_id 店铺
  8. 'default_website_id'=>env('DEFAULT_WEBSITE_ID', '1'),
  9. // 每半小时等于汽车公里数
  10. 'Kilometer'=>env('KILOMETER', '10'),
  11. // 碳排放系数
  12. 'carbon_coefficient'=>env('CARBON_COEFFICIENT', '0.785'),
  13. /*
  14. |--------------------------------------------------------------------------
  15. | Standards Tree
  16. |--------------------------------------------------------------------------
  17. |
  18. | Versioning an API with Dingo revolves around content negotiation and
  19. | custom MIME types. A custom type will belong to one of three
  20. | standards trees, the Vendor tree (vnd), the Personal tree
  21. | (prs), and the Unregistered tree (x).
  22. |
  23. | By default the Unregistered tree (x) is used, however, should you wish
  24. | to you can register your type with the IANA. For more details:
  25. | https://tools.ietf.org/html/rfc6838
  26. |
  27. */
  28. 'standardsTree' => env('API_STANDARDS_TREE', 'x'),
  29. /*
  30. |--------------------------------------------------------------------------
  31. | API Subtype
  32. |--------------------------------------------------------------------------
  33. |
  34. | Your subtype will follow the standards tree you use when used in the
  35. | "Accept" header to negotiate the content type and version.
  36. |
  37. | For example: Accept: application/x.SUBTYPE.v1+json
  38. |
  39. */
  40. 'subtype' => env('API_SUBTYPE', ''),
  41. /*
  42. |--------------------------------------------------------------------------
  43. | Default API Version
  44. |--------------------------------------------------------------------------
  45. |
  46. | This is the default version when strict mode is disabled and your API
  47. | is accessed via a web browser. It's also used as the default version
  48. | when generating your APIs documentation.
  49. |
  50. */
  51. 'version' => env('API_VERSION', 'v1'),
  52. /*
  53. |--------------------------------------------------------------------------
  54. | Default API Prefix
  55. |--------------------------------------------------------------------------
  56. |
  57. | A default prefix to use for your API routes so you don't have to
  58. | specify it for each group.
  59. |
  60. */
  61. 'prefix' => env('API_PREFIX', null),
  62. /*
  63. |--------------------------------------------------------------------------
  64. | Default API Domain
  65. |--------------------------------------------------------------------------
  66. |
  67. | A default domain to use for your API routes so you don't have to
  68. | specify it for each group.
  69. |
  70. */
  71. 'domain' => env('API_DOMAIN', null),
  72. /*
  73. |--------------------------------------------------------------------------
  74. | Name
  75. |--------------------------------------------------------------------------
  76. |
  77. | When documenting your API using the API Blueprint syntax you can
  78. | configure a default name to avoid having to manually specify
  79. | one when using the command.
  80. |
  81. */
  82. 'name' => env('API_NAME', null),
  83. /*
  84. |--------------------------------------------------------------------------
  85. | Conditional Requests
  86. |--------------------------------------------------------------------------
  87. |
  88. | Globally enable conditional requests so that an ETag header is added to
  89. | any successful response. Subsequent requests will perform a check and
  90. | will return a 304 Not Modified. This can also be enabled or disabled
  91. | on certain groups or routes.
  92. |
  93. */
  94. 'conditionalRequest' => env('API_CONDITIONAL_REQUEST', true),
  95. /*
  96. |--------------------------------------------------------------------------
  97. | Strict Mode
  98. |--------------------------------------------------------------------------
  99. |
  100. | Enabling strict mode will require clients to send a valid Accept header
  101. | with every request. This also voids the default API version, meaning
  102. | your API will not be browsable via a web browser.
  103. |
  104. */
  105. 'strict' => env('API_STRICT', false),
  106. /*
  107. |--------------------------------------------------------------------------
  108. | Debug Mode
  109. |--------------------------------------------------------------------------
  110. |
  111. | Enabling debug mode will result in error responses caused by thrown
  112. | exceptions to have a "debug" key that will be populated with
  113. | more detailed information on the exception.
  114. |
  115. */
  116. 'debug' => env('API_DEBUG', false),
  117. /*
  118. |--------------------------------------------------------------------------
  119. | Generic Error Format
  120. |--------------------------------------------------------------------------
  121. |
  122. | When some HTTP exceptions are not caught and dealt with the API will
  123. | generate a generic error response in the format provided. Any
  124. | keys that aren't replaced with corresponding values will be
  125. | removed from the final response.
  126. |
  127. */
  128. 'errorFormat' => [
  129. 'message' => ':message',
  130. 'errors' => ':errors',
  131. 'code' => ':code',
  132. 'status_code' => ':status_code',
  133. 'debug' => ':debug',
  134. ],
  135. /*
  136. |--------------------------------------------------------------------------
  137. | API Middleware
  138. |--------------------------------------------------------------------------
  139. |
  140. | Middleware that will be applied globally to all API requests.
  141. |
  142. */
  143. 'middleware' => [
  144. ],
  145. /*
  146. |--------------------------------------------------------------------------
  147. | Authentication Providers
  148. |--------------------------------------------------------------------------
  149. |
  150. | The authentication providers that should be used when attempting to
  151. | authenticate an incoming API request.
  152. |
  153. */
  154. 'auth' => [
  155. 'jwt' => 'Dingo\Api\Auth\Provider\JWT',
  156. ],
  157. /*
  158. |--------------------------------------------------------------------------
  159. | Throttling / Rate Limiting
  160. |--------------------------------------------------------------------------
  161. |
  162. | Consumers of your API can be limited to the amount of requests they can
  163. | make. You can create your own throttles or simply change the default
  164. | throttles.
  165. |
  166. */
  167. 'throttling' => [
  168. ],
  169. /*
  170. |--------------------------------------------------------------------------
  171. | Response Transformer
  172. |--------------------------------------------------------------------------
  173. |
  174. | Responses can be transformed so that they are easier to format. By
  175. | default a Fractal transformer will be used to transform any
  176. | responses prior to formatting. You can easily replace
  177. | this with your own transformer.
  178. |
  179. */
  180. 'transformer' => env('API_TRANSFORMER', Dingo\Api\Transformer\Adapter\Fractal::class),
  181. /*
  182. |--------------------------------------------------------------------------
  183. | Response Formats
  184. |--------------------------------------------------------------------------
  185. |
  186. | Responses can be returned in multiple formats by registering different
  187. | response formatters. You can also customize an existing response
  188. | formatter with a number of options to configure its output.
  189. |
  190. */
  191. 'defaultFormat' => env('API_DEFAULT_FORMAT', 'json'),
  192. 'formats' => [
  193. 'json' => Dingo\Api\Http\Response\Format\Json::class,
  194. ],
  195. 'formatsOptions' => [
  196. 'json' => [
  197. 'pretty_print' => env('API_JSON_FORMAT_PRETTY_PRINT_ENABLED', false),
  198. 'indent_style' => env('API_JSON_FORMAT_INDENT_STYLE', 'space'),
  199. 'indent_size' => env('API_JSON_FORMAT_INDENT_SIZE', 2),
  200. ],
  201. ],
  202. /*
  203. * 接口频率限制
  204. */
  205. 'rate_limits' => [
  206. // 访问频率限制,次数/分钟
  207. 'access' => [
  208. 'expires' => env('RATE_LIMITS_EXPIRES', 1),
  209. 'limit' => env('RATE_LIMITS', 60),
  210. ],
  211. // 登录相关,次数/分钟
  212. 'sign' => [
  213. 'expires' => env('SIGN_RATE_LIMITS_EXPIRES', 1),
  214. 'limit' => env('SIGN_RATE_LIMITS', 10),
  215. ],
  216. ],
  217. ];