@spinajs/http 2.0.180 → 2.0.181

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/lib/cjs/bootstrap.d.ts +4 -4
  2. package/lib/cjs/bootstrap.js +29 -29
  3. package/lib/cjs/bootstrap.js.map +1 -1
  4. package/lib/cjs/config/http.d.ts +58 -58
  5. package/lib/cjs/config/http.js +86 -86
  6. package/lib/cjs/controllers.d.ts +48 -48
  7. package/lib/cjs/controllers.d.ts.map +1 -1
  8. package/lib/cjs/controllers.js +307 -312
  9. package/lib/cjs/controllers.js.map +1 -1
  10. package/lib/cjs/decorators.d.ts +183 -183
  11. package/lib/cjs/decorators.js +441 -441
  12. package/lib/cjs/hydrators/DateTimeHydrator.d.ts +5 -5
  13. package/lib/cjs/hydrators/DateTimeHydrator.js +36 -36
  14. package/lib/cjs/hydrators/DateTimeHydrator.js.map +1 -1
  15. package/lib/cjs/index.d.ts +9 -9
  16. package/lib/cjs/index.js +25 -25
  17. package/lib/cjs/interfaces.d.ts +569 -550
  18. package/lib/cjs/interfaces.d.ts.map +1 -1
  19. package/lib/cjs/interfaces.js +266 -259
  20. package/lib/cjs/interfaces.js.map +1 -1
  21. package/lib/cjs/middlewares/RealIp.d.ts +8 -8
  22. package/lib/cjs/middlewares/RealIp.js +34 -34
  23. package/lib/cjs/middlewares/RealIp.js.map +1 -1
  24. package/lib/cjs/middlewares/RequestId.d.ts +8 -8
  25. package/lib/cjs/middlewares/RequestId.js +35 -35
  26. package/lib/cjs/middlewares/RequestId.js.map +1 -1
  27. package/lib/cjs/middlewares/ResponseTime.d.ts +10 -10
  28. package/lib/cjs/middlewares/ResponseTime.js +41 -41
  29. package/lib/cjs/middlewares/ResponseTime.js.map +1 -1
  30. package/lib/cjs/response-methods/badRequest.d.ts +12 -12
  31. package/lib/cjs/response-methods/badRequest.js +20 -20
  32. package/lib/cjs/response-methods/conflict.d.ts +12 -12
  33. package/lib/cjs/response-methods/conflict.js +20 -20
  34. package/lib/cjs/response-methods/cookieResponse.d.ts +19 -19
  35. package/lib/cjs/response-methods/cookieResponse.js +73 -73
  36. package/lib/cjs/response-methods/created.d.ts +12 -12
  37. package/lib/cjs/response-methods/created.js +19 -19
  38. package/lib/cjs/response-methods/errorResponse.d.ts +7 -7
  39. package/lib/cjs/response-methods/errorResponse.js +24 -24
  40. package/lib/cjs/response-methods/file.d.ts +26 -26
  41. package/lib/cjs/response-methods/file.d.ts.map +1 -1
  42. package/lib/cjs/response-methods/file.js +112 -133
  43. package/lib/cjs/response-methods/file.js.map +1 -1
  44. package/lib/cjs/response-methods/forbidden.d.ts +12 -12
  45. package/lib/cjs/response-methods/forbidden.js +20 -20
  46. package/lib/cjs/response-methods/index.d.ts +13 -13
  47. package/lib/cjs/response-methods/index.js +29 -29
  48. package/lib/cjs/response-methods/noContent.d.ts +12 -12
  49. package/lib/cjs/response-methods/noContent.js +20 -20
  50. package/lib/cjs/response-methods/notAcceptable.d.ts +13 -13
  51. package/lib/cjs/response-methods/notAcceptable.js +21 -21
  52. package/lib/cjs/response-methods/notAllowed.d.ts +12 -12
  53. package/lib/cjs/response-methods/notAllowed.js +20 -20
  54. package/lib/cjs/response-methods/notFound.d.ts +12 -12
  55. package/lib/cjs/response-methods/notFound.js +20 -20
  56. package/lib/cjs/response-methods/ok.d.ts +12 -12
  57. package/lib/cjs/response-methods/ok.js +19 -19
  58. package/lib/cjs/response-methods/redirect.d.ts +12 -12
  59. package/lib/cjs/response-methods/redirect.js +19 -19
  60. package/lib/cjs/response-methods/serverError.d.ts +12 -12
  61. package/lib/cjs/response-methods/serverError.js +20 -20
  62. package/lib/cjs/response-methods/template.d.ts +15 -15
  63. package/lib/cjs/response-methods/template.js +36 -36
  64. package/lib/cjs/response-methods/unauthorized.d.ts +12 -12
  65. package/lib/cjs/response-methods/unauthorized.js +20 -20
  66. package/lib/cjs/response-methods/validationError.d.ts +12 -12
  67. package/lib/cjs/response-methods/validationError.js +20 -20
  68. package/lib/cjs/responses.d.ts +34 -34
  69. package/lib/cjs/responses.js +173 -173
  70. package/lib/cjs/route-args/ArgAsRequest.d.ts +11 -11
  71. package/lib/cjs/route-args/ArgAsRequest.js +24 -24
  72. package/lib/cjs/route-args/ArgAsRequest.js.map +1 -1
  73. package/lib/cjs/route-args/ArgAsResponse.d.ts +10 -10
  74. package/lib/cjs/route-args/ArgAsResponse.js +24 -24
  75. package/lib/cjs/route-args/ArgAsResponse.js.map +1 -1
  76. package/lib/cjs/route-args/ArgHydrator.d.ts +4 -4
  77. package/lib/cjs/route-args/ArgHydrator.js +6 -6
  78. package/lib/cjs/route-args/FromBody.d.ts +10 -10
  79. package/lib/cjs/route-args/FromBody.js +26 -26
  80. package/lib/cjs/route-args/FromBody.js.map +1 -1
  81. package/lib/cjs/route-args/FromCookie.d.ts +13 -13
  82. package/lib/cjs/route-args/FromCookie.js +72 -72
  83. package/lib/cjs/route-args/FromCookie.js.map +1 -1
  84. package/lib/cjs/route-args/FromDi.d.ts +13 -13
  85. package/lib/cjs/route-args/FromDi.js +35 -35
  86. package/lib/cjs/route-args/FromDi.js.map +1 -1
  87. package/lib/cjs/route-args/FromForm.d.ts +66 -92
  88. package/lib/cjs/route-args/FromForm.d.ts.map +1 -1
  89. package/lib/cjs/route-args/FromForm.js +214 -291
  90. package/lib/cjs/route-args/FromForm.js.map +1 -1
  91. package/lib/cjs/route-args/FromHeaderArg.d.ts +10 -10
  92. package/lib/cjs/route-args/FromHeaderArg.js +25 -25
  93. package/lib/cjs/route-args/FromHeaderArg.js.map +1 -1
  94. package/lib/cjs/route-args/FromParams.d.ts +10 -10
  95. package/lib/cjs/route-args/FromParams.js +27 -27
  96. package/lib/cjs/route-args/FromParams.js.map +1 -1
  97. package/lib/cjs/route-args/FromQuery.d.ts +10 -10
  98. package/lib/cjs/route-args/FromQuery.js +27 -27
  99. package/lib/cjs/route-args/FromQuery.js.map +1 -1
  100. package/lib/cjs/route-args/RequestFields.d.ts +40 -40
  101. package/lib/cjs/route-args/RequestFields.js +110 -110
  102. package/lib/cjs/route-args/RequestFields.js.map +1 -1
  103. package/lib/cjs/route-args/RouteArgs.d.ts +22 -22
  104. package/lib/cjs/route-args/RouteArgs.js +114 -114
  105. package/lib/cjs/route-args/RouteArgs.js.map +1 -1
  106. package/lib/cjs/route-args/index.d.ts +12 -12
  107. package/lib/cjs/route-args/index.js +28 -28
  108. package/lib/cjs/schemas/RouteArgsSchemas.d.ts +36 -36
  109. package/lib/cjs/schemas/RouteArgsSchemas.js +26 -26
  110. package/lib/cjs/server.d.ts +50 -50
  111. package/lib/cjs/server.js +272 -272
  112. package/lib/cjs/server.js.map +1 -1
  113. package/lib/cjs/transformers/PureTransformer.d.ts +9 -9
  114. package/lib/cjs/transformers/PureTransformer.js +27 -27
  115. package/lib/cjs/transformers/PureTransformer.js.map +1 -1
  116. package/lib/cjs/transformers/index.d.ts +1 -1
  117. package/lib/cjs/transformers/index.js +17 -17
  118. package/lib/cjs/uploaders/ImmediateFileUploader.d.ts +19 -0
  119. package/lib/cjs/uploaders/ImmediateFileUploader.d.ts.map +1 -0
  120. package/lib/cjs/uploaders/ImmediateFileUploader.js +69 -0
  121. package/lib/cjs/uploaders/ImmediateFileUploader.js.map +1 -0
  122. package/lib/mjs/bootstrap.d.ts +4 -4
  123. package/lib/mjs/bootstrap.js +26 -26
  124. package/lib/mjs/bootstrap.js.map +1 -1
  125. package/lib/mjs/config/http.d.ts +58 -58
  126. package/lib/mjs/config/http.js +81 -81
  127. package/lib/mjs/controllers.d.ts +48 -48
  128. package/lib/mjs/controllers.d.ts.map +1 -1
  129. package/lib/mjs/controllers.js +276 -281
  130. package/lib/mjs/controllers.js.map +1 -1
  131. package/lib/mjs/decorators.d.ts +183 -183
  132. package/lib/mjs/decorators.js +404 -404
  133. package/lib/mjs/exceptions.d.ts +1 -1
  134. package/lib/mjs/exceptions.js +1 -1
  135. package/lib/mjs/hydrators/DateTimeHydrator.d.ts +5 -5
  136. package/lib/mjs/hydrators/DateTimeHydrator.js +30 -30
  137. package/lib/mjs/hydrators/DateTimeHydrator.js.map +1 -1
  138. package/lib/mjs/index.d.ts +9 -9
  139. package/lib/mjs/index.js +9 -9
  140. package/lib/mjs/interfaces.d.ts +569 -550
  141. package/lib/mjs/interfaces.d.ts.map +1 -1
  142. package/lib/mjs/interfaces.js +257 -251
  143. package/lib/mjs/interfaces.js.map +1 -1
  144. package/lib/mjs/middlewares/RealIp.d.ts +8 -8
  145. package/lib/mjs/middlewares/RealIp.js +31 -31
  146. package/lib/mjs/middlewares/RealIp.js.map +1 -1
  147. package/lib/mjs/middlewares/RequestId.d.ts +8 -8
  148. package/lib/mjs/middlewares/RequestId.js +32 -32
  149. package/lib/mjs/middlewares/RequestId.js.map +1 -1
  150. package/lib/mjs/middlewares/ResponseTime.d.ts +10 -10
  151. package/lib/mjs/middlewares/ResponseTime.js +38 -38
  152. package/lib/mjs/middlewares/ResponseTime.js.map +1 -1
  153. package/lib/mjs/response-methods/badRequest.d.ts +12 -12
  154. package/lib/mjs/response-methods/badRequest.js +16 -16
  155. package/lib/mjs/response-methods/conflict.d.ts +12 -12
  156. package/lib/mjs/response-methods/conflict.js +16 -16
  157. package/lib/mjs/response-methods/cookieResponse.d.ts +19 -19
  158. package/lib/mjs/response-methods/cookieResponse.js +46 -46
  159. package/lib/mjs/response-methods/created.d.ts +12 -12
  160. package/lib/mjs/response-methods/created.js +15 -15
  161. package/lib/mjs/response-methods/errorResponse.d.ts +7 -7
  162. package/lib/mjs/response-methods/errorResponse.js +17 -17
  163. package/lib/mjs/response-methods/file.d.ts +26 -26
  164. package/lib/mjs/response-methods/file.d.ts.map +1 -1
  165. package/lib/mjs/response-methods/file.js +103 -124
  166. package/lib/mjs/response-methods/file.js.map +1 -1
  167. package/lib/mjs/response-methods/forbidden.d.ts +12 -12
  168. package/lib/mjs/response-methods/forbidden.js +16 -16
  169. package/lib/mjs/response-methods/index.d.ts +13 -13
  170. package/lib/mjs/response-methods/index.js +13 -13
  171. package/lib/mjs/response-methods/noContent.d.ts +12 -12
  172. package/lib/mjs/response-methods/noContent.js +16 -16
  173. package/lib/mjs/response-methods/notAcceptable.d.ts +13 -13
  174. package/lib/mjs/response-methods/notAcceptable.js +17 -17
  175. package/lib/mjs/response-methods/notAllowed.d.ts +12 -12
  176. package/lib/mjs/response-methods/notAllowed.js +16 -16
  177. package/lib/mjs/response-methods/notFound.d.ts +12 -12
  178. package/lib/mjs/response-methods/notFound.js +16 -16
  179. package/lib/mjs/response-methods/ok.d.ts +12 -12
  180. package/lib/mjs/response-methods/ok.js +15 -15
  181. package/lib/mjs/response-methods/redirect.d.ts +12 -12
  182. package/lib/mjs/response-methods/redirect.js +15 -15
  183. package/lib/mjs/response-methods/serverError.d.ts +12 -12
  184. package/lib/mjs/response-methods/serverError.js +16 -16
  185. package/lib/mjs/response-methods/template.d.ts +15 -15
  186. package/lib/mjs/response-methods/template.js +29 -29
  187. package/lib/mjs/response-methods/unauthorized.d.ts +12 -12
  188. package/lib/mjs/response-methods/unauthorized.js +16 -16
  189. package/lib/mjs/response-methods/validationError.d.ts +12 -12
  190. package/lib/mjs/response-methods/validationError.js +16 -16
  191. package/lib/mjs/responses.d.ts +34 -34
  192. package/lib/mjs/responses.js +143 -143
  193. package/lib/mjs/route-args/ArgAsRequest.d.ts +11 -11
  194. package/lib/mjs/route-args/ArgAsRequest.js +21 -21
  195. package/lib/mjs/route-args/ArgAsRequest.js.map +1 -1
  196. package/lib/mjs/route-args/ArgAsResponse.d.ts +10 -10
  197. package/lib/mjs/route-args/ArgAsResponse.js +21 -21
  198. package/lib/mjs/route-args/ArgAsResponse.js.map +1 -1
  199. package/lib/mjs/route-args/ArgHydrator.d.ts +4 -4
  200. package/lib/mjs/route-args/ArgHydrator.js +2 -2
  201. package/lib/mjs/route-args/FromBody.d.ts +10 -10
  202. package/lib/mjs/route-args/FromBody.js +23 -23
  203. package/lib/mjs/route-args/FromBody.js.map +1 -1
  204. package/lib/mjs/route-args/FromCookie.d.ts +13 -13
  205. package/lib/mjs/route-args/FromCookie.js +46 -46
  206. package/lib/mjs/route-args/FromCookie.js.map +1 -1
  207. package/lib/mjs/route-args/FromDi.d.ts +13 -13
  208. package/lib/mjs/route-args/FromDi.js +32 -32
  209. package/lib/mjs/route-args/FromDi.js.map +1 -1
  210. package/lib/mjs/route-args/FromForm.d.ts +66 -92
  211. package/lib/mjs/route-args/FromForm.d.ts.map +1 -1
  212. package/lib/mjs/route-args/FromForm.js +210 -284
  213. package/lib/mjs/route-args/FromForm.js.map +1 -1
  214. package/lib/mjs/route-args/FromHeaderArg.d.ts +10 -10
  215. package/lib/mjs/route-args/FromHeaderArg.js +22 -22
  216. package/lib/mjs/route-args/FromHeaderArg.js.map +1 -1
  217. package/lib/mjs/route-args/FromParams.d.ts +10 -10
  218. package/lib/mjs/route-args/FromParams.js +24 -24
  219. package/lib/mjs/route-args/FromParams.js.map +1 -1
  220. package/lib/mjs/route-args/FromQuery.d.ts +10 -10
  221. package/lib/mjs/route-args/FromQuery.js +24 -24
  222. package/lib/mjs/route-args/FromQuery.js.map +1 -1
  223. package/lib/mjs/route-args/RequestFields.d.ts +40 -40
  224. package/lib/mjs/route-args/RequestFields.js +107 -107
  225. package/lib/mjs/route-args/RequestFields.js.map +1 -1
  226. package/lib/mjs/route-args/RouteArgs.d.ts +22 -22
  227. package/lib/mjs/route-args/RouteArgs.js +107 -107
  228. package/lib/mjs/route-args/RouteArgs.js.map +1 -1
  229. package/lib/mjs/route-args/index.d.ts +12 -12
  230. package/lib/mjs/route-args/index.js +12 -12
  231. package/lib/mjs/schemas/RouteArgsSchemas.d.ts +36 -36
  232. package/lib/mjs/schemas/RouteArgsSchemas.js +23 -23
  233. package/lib/mjs/server.d.ts +50 -50
  234. package/lib/mjs/server.js +266 -266
  235. package/lib/mjs/server.js.map +1 -1
  236. package/lib/mjs/transformers/PureTransformer.d.ts +9 -9
  237. package/lib/mjs/transformers/PureTransformer.js +24 -24
  238. package/lib/mjs/transformers/PureTransformer.js.map +1 -1
  239. package/lib/mjs/transformers/index.d.ts +1 -1
  240. package/lib/mjs/transformers/index.js +1 -1
  241. package/lib/mjs/uploaders/ImmediateFileUploader.d.ts +19 -0
  242. package/lib/mjs/uploaders/ImmediateFileUploader.d.ts.map +1 -0
  243. package/lib/mjs/uploaders/ImmediateFileUploader.js +66 -0
  244. package/lib/mjs/uploaders/ImmediateFileUploader.js.map +1 -0
  245. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  246. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  247. package/package.json +17 -17
@@ -1,17 +1,17 @@
1
- import { HTTP_STATUS_CODE } from '../interfaces.js';
2
- import { httpResponse } from '../responses.js';
3
- import { ErrorResponse } from './errorResponse.js';
4
- /**
5
- * Internall response function.
6
- * Returns HTTP 403 FORBIDDEN ERROR
7
- * @param err - error to send
8
- */
9
- export class NotAllowed extends ErrorResponse {
10
- constructor(data) {
11
- super(data);
12
- }
13
- async execute(_req, _res) {
14
- return await httpResponse(this.responseData, HTTP_STATUS_CODE.NOT_ALLOWED, 'not-allowed.pug');
15
- }
16
- }
1
+ import { HTTP_STATUS_CODE } from '../interfaces.js';
2
+ import { httpResponse } from '../responses.js';
3
+ import { ErrorResponse } from './errorResponse.js';
4
+ /**
5
+ * Internall response function.
6
+ * Returns HTTP 403 FORBIDDEN ERROR
7
+ * @param err - error to send
8
+ */
9
+ export class NotAllowed extends ErrorResponse {
10
+ constructor(data) {
11
+ super(data);
12
+ }
13
+ async execute(_req, _res) {
14
+ return await httpResponse(this.responseData, HTTP_STATUS_CODE.NOT_ALLOWED, 'not-allowed.pug');
15
+ }
16
+ }
17
17
  //# sourceMappingURL=notAllowed.js.map
@@ -1,13 +1,13 @@
1
- /// <reference types="qs" />
2
- import * as express from 'express';
3
- import { ErrorResponse } from './errorResponse.js';
4
- /**
5
- * Internall response function.
6
- * Returns HTTP 404 NOT FOUND ERROR
7
- * @param err - error to send
8
- */
9
- export declare class NotFound extends ErrorResponse {
10
- constructor(data?: any);
11
- execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
12
- }
1
+ /// <reference types="qs" />
2
+ import * as express from 'express';
3
+ import { ErrorResponse } from './errorResponse.js';
4
+ /**
5
+ * Internall response function.
6
+ * Returns HTTP 404 NOT FOUND ERROR
7
+ * @param err - error to send
8
+ */
9
+ export declare class NotFound extends ErrorResponse {
10
+ constructor(data?: any);
11
+ execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
12
+ }
13
13
  //# sourceMappingURL=notFound.d.ts.map
@@ -1,17 +1,17 @@
1
- import { HTTP_STATUS_CODE } from '../interfaces.js';
2
- import { httpResponse } from '../responses.js';
3
- import { ErrorResponse } from './errorResponse.js';
4
- /**
5
- * Internall response function.
6
- * Returns HTTP 404 NOT FOUND ERROR
7
- * @param err - error to send
8
- */
9
- export class NotFound extends ErrorResponse {
10
- constructor(data) {
11
- super(data);
12
- }
13
- async execute(_req, _res) {
14
- return await httpResponse(this.responseData, HTTP_STATUS_CODE.NOT_FOUND, 'notFound.pug');
15
- }
16
- }
1
+ import { HTTP_STATUS_CODE } from '../interfaces.js';
2
+ import { httpResponse } from '../responses.js';
3
+ import { ErrorResponse } from './errorResponse.js';
4
+ /**
5
+ * Internall response function.
6
+ * Returns HTTP 404 NOT FOUND ERROR
7
+ * @param err - error to send
8
+ */
9
+ export class NotFound extends ErrorResponse {
10
+ constructor(data) {
11
+ super(data);
12
+ }
13
+ async execute(_req, _res) {
14
+ return await httpResponse(this.responseData, HTTP_STATUS_CODE.NOT_FOUND, 'notFound.pug');
15
+ }
16
+ }
17
17
  //# sourceMappingURL=notFound.js.map
@@ -1,13 +1,13 @@
1
- /// <reference types="qs" />
2
- import * as express from 'express';
3
- import { Response } from '../interfaces.js';
4
- /**
5
- * Internall response function.
6
- * Returns HTTP 200 OK response with json content
7
- * @param data - data to send
8
- */
9
- export declare class Ok extends Response {
10
- constructor(data?: any);
11
- execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
12
- }
1
+ /// <reference types="qs" />
2
+ import * as express from 'express';
3
+ import { Response } from '../interfaces.js';
4
+ /**
5
+ * Internall response function.
6
+ * Returns HTTP 200 OK response with json content
7
+ * @param data - data to send
8
+ */
9
+ export declare class Ok extends Response {
10
+ constructor(data?: any);
11
+ execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
12
+ }
13
13
  //# sourceMappingURL=ok.d.ts.map
@@ -1,16 +1,16 @@
1
- import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
2
- import { httpResponse } from '../responses.js';
3
- /**
4
- * Internall response function.
5
- * Returns HTTP 200 OK response with json content
6
- * @param data - data to send
7
- */
8
- export class Ok extends Response {
9
- constructor(data) {
10
- super(data);
11
- }
12
- async execute(_req, _res) {
13
- return await httpResponse(this.responseData, HTTP_STATUS_CODE.OK, 'ok.pug');
14
- }
15
- }
1
+ import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
2
+ import { httpResponse } from '../responses.js';
3
+ /**
4
+ * Internall response function.
5
+ * Returns HTTP 200 OK response with json content
6
+ * @param data - data to send
7
+ */
8
+ export class Ok extends Response {
9
+ constructor(data) {
10
+ super(data);
11
+ }
12
+ async execute(_req, _res) {
13
+ return await httpResponse(this.responseData, HTTP_STATUS_CODE.OK, 'ok.pug');
14
+ }
15
+ }
16
16
  //# sourceMappingURL=ok.js.map
@@ -1,13 +1,13 @@
1
- import * as express from 'express';
2
- import { Response } from '../interfaces.js';
3
- /**
4
- * Redirects to another route ( simple alias for request.redirect for api consistency)
5
- *
6
- * @param url - url path to another location
7
- */
8
- export declare class Redirect extends Response {
9
- protected url: string;
10
- constructor(url: any);
11
- execute(_req: express.Request, res: express.Response): Promise<void>;
12
- }
1
+ import * as express from 'express';
2
+ import { Response } from '../interfaces.js';
3
+ /**
4
+ * Redirects to another route ( simple alias for request.redirect for api consistency)
5
+ *
6
+ * @param url - url path to another location
7
+ */
8
+ export declare class Redirect extends Response {
9
+ protected url: string;
10
+ constructor(url: any);
11
+ execute(_req: express.Request, res: express.Response): Promise<void>;
12
+ }
13
13
  //# sourceMappingURL=redirect.d.ts.map
@@ -1,16 +1,16 @@
1
- import { Response } from '../interfaces.js';
2
- /**
3
- * Redirects to another route ( simple alias for request.redirect for api consistency)
4
- *
5
- * @param url - url path to another location
6
- */
7
- export class Redirect extends Response {
8
- constructor(url) {
9
- super(null);
10
- this.url = url;
11
- }
12
- async execute(_req, res) {
13
- res.redirect(this.url);
14
- }
15
- }
1
+ import { Response } from '../interfaces.js';
2
+ /**
3
+ * Redirects to another route ( simple alias for request.redirect for api consistency)
4
+ *
5
+ * @param url - url path to another location
6
+ */
7
+ export class Redirect extends Response {
8
+ constructor(url) {
9
+ super(null);
10
+ this.url = url;
11
+ }
12
+ async execute(_req, res) {
13
+ res.redirect(this.url);
14
+ }
15
+ }
16
16
  //# sourceMappingURL=redirect.js.map
@@ -1,13 +1,13 @@
1
- /// <reference types="qs" />
2
- import * as express from 'express';
3
- import { ErrorResponse } from './errorResponse.js';
4
- /**
5
- * Internall response function.
6
- * Returns HTTP 500 INTERNAL SERVER ERROR
7
- * @param err - error to send
8
- */
9
- export declare class ServerError extends ErrorResponse {
10
- constructor(data: any);
11
- execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
12
- }
1
+ /// <reference types="qs" />
2
+ import * as express from 'express';
3
+ import { ErrorResponse } from './errorResponse.js';
4
+ /**
5
+ * Internall response function.
6
+ * Returns HTTP 500 INTERNAL SERVER ERROR
7
+ * @param err - error to send
8
+ */
9
+ export declare class ServerError extends ErrorResponse {
10
+ constructor(data: any);
11
+ execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
12
+ }
13
13
  //# sourceMappingURL=serverError.d.ts.map
@@ -1,17 +1,17 @@
1
- import { HTTP_STATUS_CODE } from '../interfaces.js';
2
- import { httpResponse } from '../responses.js';
3
- import { ErrorResponse } from './errorResponse.js';
4
- /**
5
- * Internall response function.
6
- * Returns HTTP 500 INTERNAL SERVER ERROR
7
- * @param err - error to send
8
- */
9
- export class ServerError extends ErrorResponse {
10
- constructor(data) {
11
- super(data);
12
- }
13
- async execute(_req, _res) {
14
- return await httpResponse({ error: this.responseData }, HTTP_STATUS_CODE.INTERNAL_ERROR, 'serverError.pug');
15
- }
16
- }
1
+ import { HTTP_STATUS_CODE } from '../interfaces.js';
2
+ import { httpResponse } from '../responses.js';
3
+ import { ErrorResponse } from './errorResponse.js';
4
+ /**
5
+ * Internall response function.
6
+ * Returns HTTP 500 INTERNAL SERVER ERROR
7
+ * @param err - error to send
8
+ */
9
+ export class ServerError extends ErrorResponse {
10
+ constructor(data) {
11
+ super(data);
12
+ }
13
+ async execute(_req, _res) {
14
+ return await httpResponse({ error: this.responseData }, HTTP_STATUS_CODE.INTERNAL_ERROR, 'serverError.pug');
15
+ }
16
+ }
17
17
  //# sourceMappingURL=serverError.js.map
@@ -1,16 +1,16 @@
1
- /// <reference types="qs" />
2
- import { fs } from '@spinajs/fs';
3
- import * as express from 'express';
4
- import { HTTP_STATUS_CODE, ITemplateResponseOptions, Response } from '../interfaces.js';
5
- /**
6
- * HTML resposne with HTML from pug file
7
- */
8
- export declare class TemplateResponse extends Response {
9
- protected file: string;
10
- protected status: HTTP_STATUS_CODE;
11
- protected fsTemplates: fs;
12
- protected templateFile: string | ITemplateResponseOptions;
13
- constructor(file: string | ITemplateResponseOptions, model: any, status?: HTTP_STATUS_CODE);
14
- execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
15
- }
1
+ /// <reference types="qs" />
2
+ import { fs } from '@spinajs/fs';
3
+ import * as express from 'express';
4
+ import { HTTP_STATUS_CODE, ITemplateResponseOptions, Response } from '../interfaces.js';
5
+ /**
6
+ * HTML resposne with HTML from pug file
7
+ */
8
+ export declare class TemplateResponse extends Response {
9
+ protected file: string;
10
+ protected status: HTTP_STATUS_CODE;
11
+ protected fsTemplates: fs;
12
+ protected templateFile: string | ITemplateResponseOptions;
13
+ constructor(file: string | ITemplateResponseOptions, model: any, status?: HTTP_STATUS_CODE);
14
+ execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
15
+ }
16
16
  //# sourceMappingURL=template.d.ts.map
@@ -1,30 +1,30 @@
1
- import { DI } from '@spinajs/di';
2
- import { IOFail } from '@spinajs/exceptions';
3
- import _ from 'lodash';
4
- import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
5
- import { htmlResponse } from '../responses.js';
6
- /**
7
- * HTML resposne with HTML from pug file
8
- */
9
- export class TemplateResponse extends Response {
10
- constructor(file, model, status) {
11
- super(model);
12
- this.status = null;
13
- this.fsTemplates = _.isString(file)
14
- ? DI.resolve('__file_provider__', ['__fs_http_templates__'])
15
- : DI.resolve('__file_provider__', [file.provider]);
16
- this.templateFile = file;
17
- this.status = status;
18
- }
19
- async execute(_req, _res) {
20
- if (!this.fsTemplates) {
21
- const provider = _.isString(this.templateFile) ? '__fs_http_templates__' : this.templateFile.provider;
22
- throw new IOFail(`Cannot find template file provider ${provider}. Please check configuration for provider or make sure that __fs_http_templates__ is configured.`);
23
- }
24
- this.file = _.isString(this.templateFile)
25
- ? await this.fsTemplates.download(this.templateFile)
26
- : await this.fsTemplates.download(this.templateFile.template);
27
- return await htmlResponse(this.file, this.responseData, this.status ? this.status : HTTP_STATUS_CODE.OK);
28
- }
29
- }
1
+ import { DI } from '@spinajs/di';
2
+ import { IOFail } from '@spinajs/exceptions';
3
+ import _ from 'lodash';
4
+ import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
5
+ import { htmlResponse } from '../responses.js';
6
+ /**
7
+ * HTML resposne with HTML from pug file
8
+ */
9
+ export class TemplateResponse extends Response {
10
+ constructor(file, model, status) {
11
+ super(model);
12
+ this.status = null;
13
+ this.fsTemplates = _.isString(file)
14
+ ? DI.resolve('__file_provider__', ['__fs_http_templates__'])
15
+ : DI.resolve('__file_provider__', [file.provider]);
16
+ this.templateFile = file;
17
+ this.status = status;
18
+ }
19
+ async execute(_req, _res) {
20
+ if (!this.fsTemplates) {
21
+ const provider = _.isString(this.templateFile) ? '__fs_http_templates__' : this.templateFile.provider;
22
+ throw new IOFail(`Cannot find template file provider ${provider}. Please check configuration for provider or make sure that __fs_http_templates__ is configured.`);
23
+ }
24
+ this.file = _.isString(this.templateFile)
25
+ ? await this.fsTemplates.download(this.templateFile)
26
+ : await this.fsTemplates.download(this.templateFile.template);
27
+ return await htmlResponse(this.file, this.responseData, this.status ? this.status : HTTP_STATUS_CODE.OK);
28
+ }
29
+ }
30
30
  //# sourceMappingURL=template.js.map
@@ -1,13 +1,13 @@
1
- /// <reference types="qs" />
2
- import * as express from 'express';
3
- import { ErrorResponse } from './errorResponse.js';
4
- /**
5
- * Internall response function.
6
- * Returns HTTP 401 UNAHTORIZED response with json content
7
- * @param data - data to send
8
- */
9
- export declare class Unauthorized extends ErrorResponse {
10
- constructor(data: any);
11
- execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
12
- }
1
+ /// <reference types="qs" />
2
+ import * as express from 'express';
3
+ import { ErrorResponse } from './errorResponse.js';
4
+ /**
5
+ * Internall response function.
6
+ * Returns HTTP 401 UNAHTORIZED response with json content
7
+ * @param data - data to send
8
+ */
9
+ export declare class Unauthorized extends ErrorResponse {
10
+ constructor(data: any);
11
+ execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
12
+ }
13
13
  //# sourceMappingURL=unauthorized.d.ts.map
@@ -1,17 +1,17 @@
1
- import { HTTP_STATUS_CODE } from '../interfaces.js';
2
- import { httpResponse } from '../responses.js';
3
- import { ErrorResponse } from './errorResponse.js';
4
- /**
5
- * Internall response function.
6
- * Returns HTTP 401 UNAHTORIZED response with json content
7
- * @param data - data to send
8
- */
9
- export class Unauthorized extends ErrorResponse {
10
- constructor(data) {
11
- super(data);
12
- }
13
- async execute(_req, _res) {
14
- return await httpResponse(this.responseData, HTTP_STATUS_CODE.UNAUTHORIZED, 'responses/unauthorized');
15
- }
16
- }
1
+ import { HTTP_STATUS_CODE } from '../interfaces.js';
2
+ import { httpResponse } from '../responses.js';
3
+ import { ErrorResponse } from './errorResponse.js';
4
+ /**
5
+ * Internall response function.
6
+ * Returns HTTP 401 UNAHTORIZED response with json content
7
+ * @param data - data to send
8
+ */
9
+ export class Unauthorized extends ErrorResponse {
10
+ constructor(data) {
11
+ super(data);
12
+ }
13
+ async execute(_req, _res) {
14
+ return await httpResponse(this.responseData, HTTP_STATUS_CODE.UNAUTHORIZED, 'responses/unauthorized');
15
+ }
16
+ }
17
17
  //# sourceMappingURL=unauthorized.js.map
@@ -1,13 +1,13 @@
1
- /// <reference types="qs" />
2
- import * as express from 'express';
3
- import { ErrorResponse } from './errorResponse.js';
4
- /**
5
- * Internall response function.
6
- * Returns HTTP 400 BAD REQUEST ERROR
7
- * @param err - error to send
8
- */
9
- export declare class ValidationError extends ErrorResponse {
10
- constructor(data: any);
11
- execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
12
- }
1
+ /// <reference types="qs" />
2
+ import * as express from 'express';
3
+ import { ErrorResponse } from './errorResponse.js';
4
+ /**
5
+ * Internall response function.
6
+ * Returns HTTP 400 BAD REQUEST ERROR
7
+ * @param err - error to send
8
+ */
9
+ export declare class ValidationError extends ErrorResponse {
10
+ constructor(data: any);
11
+ execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
12
+ }
13
13
  //# sourceMappingURL=validationError.d.ts.map
@@ -1,17 +1,17 @@
1
- import { HTTP_STATUS_CODE } from '../interfaces.js';
2
- import { httpResponse } from '../responses.js';
3
- import { ErrorResponse } from './errorResponse.js';
4
- /**
5
- * Internall response function.
6
- * Returns HTTP 400 BAD REQUEST ERROR
7
- * @param err - error to send
8
- */
9
- export class ValidationError extends ErrorResponse {
10
- constructor(data) {
11
- super(data);
12
- }
13
- async execute(_req, _res) {
14
- return await httpResponse(this.responseData, HTTP_STATUS_CODE.BAD_REQUEST, 'validationError.pug');
15
- }
16
- }
1
+ import { HTTP_STATUS_CODE } from '../interfaces.js';
2
+ import { httpResponse } from '../responses.js';
3
+ import { ErrorResponse } from './errorResponse.js';
4
+ /**
5
+ * Internall response function.
6
+ * Returns HTTP 400 BAD REQUEST ERROR
7
+ * @param err - error to send
8
+ */
9
+ export class ValidationError extends ErrorResponse {
10
+ constructor(data) {
11
+ super(data);
12
+ }
13
+ async execute(_req, _res) {
14
+ return await httpResponse(this.responseData, HTTP_STATUS_CODE.BAD_REQUEST, 'validationError.pug');
15
+ }
16
+ }
17
17
  //# sourceMappingURL=validationError.js.map
@@ -1,35 +1,35 @@
1
- import * as express from 'express';
2
- import { HTTP_STATUS_CODE } from './interfaces.js';
3
- /**
4
- * Sends data & sets proper header as json
5
- *
6
- * @param model - data to send
7
- * @param status - status code
8
- */
9
- export declare function jsonResponse(model: any, status?: HTTP_STATUS_CODE): (_req: express.Request, res: express.Response) => void;
10
- /**
11
- * Sends data & sets proper header as json
12
- *
13
- * @param model - data to send
14
- * @param status - status code
15
- */
16
- export declare function textResponse(model: any, status?: HTTP_STATUS_CODE): (_req: express.Request, res: express.Response) => void;
17
- /**
18
- * Sends html response & sets proper header. If template is not avaible, handles proper error rendering.
19
- *
20
- * @param file - template file path
21
- * @param model - data passed to template
22
- * @param status - optional status code
23
- */
24
- export declare function htmlResponse(file: string, model: any, status?: HTTP_STATUS_CODE): (req: express.Request, res: express.Response) => void;
25
- /**
26
- * Default response handling. Checks `Accept` header & matches proper response
27
- * For now its supports html & json responses
28
- *
29
- * @param model - data to send
30
- * @param code - status code
31
- * @param template - template to render without extension eg. `views/responses/ok`. It will try to match .pug, .xml or whatever to match response
32
- * to `Accept` header
33
- */
34
- export declare function httpResponse(model: any, code: HTTP_STATUS_CODE, template: string): (req: express.Request, res: express.Response) => void;
1
+ import * as express from 'express';
2
+ import { HTTP_STATUS_CODE } from './interfaces.js';
3
+ /**
4
+ * Sends data & sets proper header as json
5
+ *
6
+ * @param model - data to send
7
+ * @param status - status code
8
+ */
9
+ export declare function jsonResponse(model: any, status?: HTTP_STATUS_CODE): (_req: express.Request, res: express.Response) => void;
10
+ /**
11
+ * Sends data & sets proper header as json
12
+ *
13
+ * @param model - data to send
14
+ * @param status - status code
15
+ */
16
+ export declare function textResponse(model: any, status?: HTTP_STATUS_CODE): (_req: express.Request, res: express.Response) => void;
17
+ /**
18
+ * Sends html response & sets proper header. If template is not avaible, handles proper error rendering.
19
+ *
20
+ * @param file - template file path
21
+ * @param model - data passed to template
22
+ * @param status - optional status code
23
+ */
24
+ export declare function htmlResponse(file: string, model: any, status?: HTTP_STATUS_CODE): (req: express.Request, res: express.Response) => void;
25
+ /**
26
+ * Default response handling. Checks `Accept` header & matches proper response
27
+ * For now its supports html & json responses
28
+ *
29
+ * @param model - data to send
30
+ * @param code - status code
31
+ * @param template - template to render without extension eg. `views/responses/ok`. It will try to match .pug, .xml or whatever to match response
32
+ * to `Accept` header
33
+ */
34
+ export declare function httpResponse(model: any, code: HTTP_STATUS_CODE, template: string): (req: express.Request, res: express.Response) => void;
35
35
  //# sourceMappingURL=responses.d.ts.map