@spinajs/http 2.0.184 → 2.0.186

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 (179) hide show
  1. package/lib/cjs/interfaces.d.ts +19 -0
  2. package/lib/cjs/interfaces.d.ts.map +1 -1
  3. package/lib/cjs/interfaces.js +4 -0
  4. package/lib/cjs/interfaces.js.map +1 -1
  5. package/lib/cjs/middlewares/RequestId.d.ts +1 -1
  6. package/lib/cjs/middlewares/RequestId.d.ts.map +1 -1
  7. package/lib/cjs/middlewares/RequestId.js +4 -1
  8. package/lib/cjs/middlewares/RequestId.js.map +1 -1
  9. package/lib/cjs/response-methods/badRequest.d.ts +4 -8
  10. package/lib/cjs/response-methods/badRequest.d.ts.map +1 -1
  11. package/lib/cjs/response-methods/badRequest.js +18 -10
  12. package/lib/cjs/response-methods/badRequest.js.map +1 -1
  13. package/lib/cjs/response-methods/conflict.d.ts +5 -3
  14. package/lib/cjs/response-methods/conflict.d.ts.map +1 -1
  15. package/lib/cjs/response-methods/conflict.js +8 -4
  16. package/lib/cjs/response-methods/conflict.js.map +1 -1
  17. package/lib/cjs/response-methods/created.d.ts +3 -2
  18. package/lib/cjs/response-methods/created.d.ts.map +1 -1
  19. package/lib/cjs/response-methods/created.js +6 -2
  20. package/lib/cjs/response-methods/created.js.map +1 -1
  21. package/lib/cjs/response-methods/entityTooLarge.d.ts +3 -2
  22. package/lib/cjs/response-methods/entityTooLarge.d.ts.map +1 -1
  23. package/lib/cjs/response-methods/entityTooLarge.js +6 -2
  24. package/lib/cjs/response-methods/entityTooLarge.js.map +1 -1
  25. package/lib/cjs/response-methods/file.d.ts +7 -4
  26. package/lib/cjs/response-methods/file.d.ts.map +1 -1
  27. package/lib/cjs/response-methods/file.js +13 -3
  28. package/lib/cjs/response-methods/file.js.map +1 -1
  29. package/lib/cjs/response-methods/forbidden.d.ts +5 -3
  30. package/lib/cjs/response-methods/forbidden.d.ts.map +1 -1
  31. package/lib/cjs/response-methods/forbidden.js +8 -4
  32. package/lib/cjs/response-methods/forbidden.js.map +1 -1
  33. package/lib/cjs/response-methods/index.d.ts +0 -1
  34. package/lib/cjs/response-methods/index.d.ts.map +1 -1
  35. package/lib/cjs/response-methods/index.js +0 -1
  36. package/lib/cjs/response-methods/index.js.map +1 -1
  37. package/lib/cjs/response-methods/noContent.d.ts +5 -3
  38. package/lib/cjs/response-methods/noContent.d.ts.map +1 -1
  39. package/lib/cjs/response-methods/noContent.js +8 -4
  40. package/lib/cjs/response-methods/noContent.js.map +1 -1
  41. package/lib/cjs/response-methods/notAcceptable.d.ts +5 -3
  42. package/lib/cjs/response-methods/notAcceptable.d.ts.map +1 -1
  43. package/lib/cjs/response-methods/notAcceptable.js +8 -4
  44. package/lib/cjs/response-methods/notAcceptable.js.map +1 -1
  45. package/lib/cjs/response-methods/notAllowed.d.ts +5 -3
  46. package/lib/cjs/response-methods/notAllowed.d.ts.map +1 -1
  47. package/lib/cjs/response-methods/notAllowed.js +8 -4
  48. package/lib/cjs/response-methods/notAllowed.js.map +1 -1
  49. package/lib/cjs/response-methods/notFound.d.ts +5 -3
  50. package/lib/cjs/response-methods/notFound.d.ts.map +1 -1
  51. package/lib/cjs/response-methods/notFound.js +8 -4
  52. package/lib/cjs/response-methods/notFound.js.map +1 -1
  53. package/lib/cjs/response-methods/ok.d.ts +3 -2
  54. package/lib/cjs/response-methods/ok.d.ts.map +1 -1
  55. package/lib/cjs/response-methods/ok.js +6 -2
  56. package/lib/cjs/response-methods/ok.js.map +1 -1
  57. package/lib/cjs/response-methods/serverError.d.ts +5 -3
  58. package/lib/cjs/response-methods/serverError.d.ts.map +1 -1
  59. package/lib/cjs/response-methods/serverError.js +8 -4
  60. package/lib/cjs/response-methods/serverError.js.map +1 -1
  61. package/lib/cjs/response-methods/template.d.ts +3 -3
  62. package/lib/cjs/response-methods/template.d.ts.map +1 -1
  63. package/lib/cjs/response-methods/template.js +6 -4
  64. package/lib/cjs/response-methods/template.js.map +1 -1
  65. package/lib/cjs/response-methods/unauthorized.d.ts +5 -3
  66. package/lib/cjs/response-methods/unauthorized.d.ts.map +1 -1
  67. package/lib/cjs/response-methods/unauthorized.js +8 -4
  68. package/lib/cjs/response-methods/unauthorized.js.map +1 -1
  69. package/lib/cjs/response-methods/validationError.d.ts +5 -3
  70. package/lib/cjs/response-methods/validationError.d.ts.map +1 -1
  71. package/lib/cjs/response-methods/validationError.js +8 -4
  72. package/lib/cjs/response-methods/validationError.js.map +1 -1
  73. package/lib/cjs/responses.d.ts +7 -5
  74. package/lib/cjs/responses.d.ts.map +1 -1
  75. package/lib/cjs/responses.js +54 -15
  76. package/lib/cjs/responses.js.map +1 -1
  77. package/lib/cjs/route-args/FromSession.d.ts +1 -0
  78. package/lib/cjs/route-args/FromSession.d.ts.map +1 -0
  79. package/lib/cjs/route-args/FromSession.js +1 -0
  80. package/lib/cjs/route-args/FromSession.js.map +1 -0
  81. package/lib/mjs/interfaces.d.ts +19 -0
  82. package/lib/mjs/interfaces.d.ts.map +1 -1
  83. package/lib/mjs/interfaces.js +4 -0
  84. package/lib/mjs/interfaces.js.map +1 -1
  85. package/lib/mjs/middlewares/RequestId.d.ts +1 -1
  86. package/lib/mjs/middlewares/RequestId.d.ts.map +1 -1
  87. package/lib/mjs/middlewares/RequestId.js +4 -1
  88. package/lib/mjs/middlewares/RequestId.js.map +1 -1
  89. package/lib/mjs/response-methods/badRequest.d.ts +4 -8
  90. package/lib/mjs/response-methods/badRequest.d.ts.map +1 -1
  91. package/lib/mjs/response-methods/badRequest.js +16 -11
  92. package/lib/mjs/response-methods/badRequest.js.map +1 -1
  93. package/lib/mjs/response-methods/conflict.d.ts +5 -3
  94. package/lib/mjs/response-methods/conflict.d.ts.map +1 -1
  95. package/lib/mjs/response-methods/conflict.js +8 -4
  96. package/lib/mjs/response-methods/conflict.js.map +1 -1
  97. package/lib/mjs/response-methods/created.d.ts +3 -2
  98. package/lib/mjs/response-methods/created.d.ts.map +1 -1
  99. package/lib/mjs/response-methods/created.js +6 -2
  100. package/lib/mjs/response-methods/created.js.map +1 -1
  101. package/lib/mjs/response-methods/entityTooLarge.d.ts +3 -2
  102. package/lib/mjs/response-methods/entityTooLarge.d.ts.map +1 -1
  103. package/lib/mjs/response-methods/entityTooLarge.js +6 -2
  104. package/lib/mjs/response-methods/entityTooLarge.js.map +1 -1
  105. package/lib/mjs/response-methods/file.d.ts +7 -4
  106. package/lib/mjs/response-methods/file.d.ts.map +1 -1
  107. package/lib/mjs/response-methods/file.js +13 -3
  108. package/lib/mjs/response-methods/file.js.map +1 -1
  109. package/lib/mjs/response-methods/forbidden.d.ts +5 -3
  110. package/lib/mjs/response-methods/forbidden.d.ts.map +1 -1
  111. package/lib/mjs/response-methods/forbidden.js +8 -4
  112. package/lib/mjs/response-methods/forbidden.js.map +1 -1
  113. package/lib/mjs/response-methods/index.d.ts +0 -1
  114. package/lib/mjs/response-methods/index.d.ts.map +1 -1
  115. package/lib/mjs/response-methods/index.js +0 -1
  116. package/lib/mjs/response-methods/index.js.map +1 -1
  117. package/lib/mjs/response-methods/noContent.d.ts +5 -3
  118. package/lib/mjs/response-methods/noContent.d.ts.map +1 -1
  119. package/lib/mjs/response-methods/noContent.js +8 -4
  120. package/lib/mjs/response-methods/noContent.js.map +1 -1
  121. package/lib/mjs/response-methods/notAcceptable.d.ts +5 -3
  122. package/lib/mjs/response-methods/notAcceptable.d.ts.map +1 -1
  123. package/lib/mjs/response-methods/notAcceptable.js +8 -4
  124. package/lib/mjs/response-methods/notAcceptable.js.map +1 -1
  125. package/lib/mjs/response-methods/notAllowed.d.ts +5 -3
  126. package/lib/mjs/response-methods/notAllowed.d.ts.map +1 -1
  127. package/lib/mjs/response-methods/notAllowed.js +8 -4
  128. package/lib/mjs/response-methods/notAllowed.js.map +1 -1
  129. package/lib/mjs/response-methods/notFound.d.ts +5 -3
  130. package/lib/mjs/response-methods/notFound.d.ts.map +1 -1
  131. package/lib/mjs/response-methods/notFound.js +8 -4
  132. package/lib/mjs/response-methods/notFound.js.map +1 -1
  133. package/lib/mjs/response-methods/ok.d.ts +3 -2
  134. package/lib/mjs/response-methods/ok.d.ts.map +1 -1
  135. package/lib/mjs/response-methods/ok.js +6 -2
  136. package/lib/mjs/response-methods/ok.js.map +1 -1
  137. package/lib/mjs/response-methods/serverError.d.ts +5 -3
  138. package/lib/mjs/response-methods/serverError.d.ts.map +1 -1
  139. package/lib/mjs/response-methods/serverError.js +8 -4
  140. package/lib/mjs/response-methods/serverError.js.map +1 -1
  141. package/lib/mjs/response-methods/template.d.ts +3 -3
  142. package/lib/mjs/response-methods/template.d.ts.map +1 -1
  143. package/lib/mjs/response-methods/template.js +6 -4
  144. package/lib/mjs/response-methods/template.js.map +1 -1
  145. package/lib/mjs/response-methods/unauthorized.d.ts +5 -3
  146. package/lib/mjs/response-methods/unauthorized.d.ts.map +1 -1
  147. package/lib/mjs/response-methods/unauthorized.js +8 -4
  148. package/lib/mjs/response-methods/unauthorized.js.map +1 -1
  149. package/lib/mjs/response-methods/validationError.d.ts +5 -3
  150. package/lib/mjs/response-methods/validationError.d.ts.map +1 -1
  151. package/lib/mjs/response-methods/validationError.js +8 -4
  152. package/lib/mjs/response-methods/validationError.js.map +1 -1
  153. package/lib/mjs/responses.d.ts +7 -5
  154. package/lib/mjs/responses.d.ts.map +1 -1
  155. package/lib/mjs/responses.js +51 -14
  156. package/lib/mjs/responses.js.map +1 -1
  157. package/lib/mjs/route-args/FromSession.d.ts +2 -0
  158. package/lib/mjs/route-args/FromSession.d.ts.map +1 -0
  159. package/lib/mjs/route-args/FromSession.js +2 -0
  160. package/lib/mjs/route-args/FromSession.js.map +1 -0
  161. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  162. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  163. package/package.json +11 -11
  164. package/lib/cjs/response-methods/cookieResponse.d.ts +0 -20
  165. package/lib/cjs/response-methods/cookieResponse.d.ts.map +0 -1
  166. package/lib/cjs/response-methods/cookieResponse.js +0 -74
  167. package/lib/cjs/response-methods/cookieResponse.js.map +0 -1
  168. package/lib/cjs/response-methods/errorResponse.d.ts +0 -8
  169. package/lib/cjs/response-methods/errorResponse.d.ts.map +0 -1
  170. package/lib/cjs/response-methods/errorResponse.js +0 -25
  171. package/lib/cjs/response-methods/errorResponse.js.map +0 -1
  172. package/lib/mjs/response-methods/cookieResponse.d.ts +0 -20
  173. package/lib/mjs/response-methods/cookieResponse.d.ts.map +0 -1
  174. package/lib/mjs/response-methods/cookieResponse.js +0 -47
  175. package/lib/mjs/response-methods/cookieResponse.js.map +0 -1
  176. package/lib/mjs/response-methods/errorResponse.d.ts +0 -8
  177. package/lib/mjs/response-methods/errorResponse.d.ts.map +0 -1
  178. package/lib/mjs/response-methods/errorResponse.js +0 -18
  179. package/lib/mjs/response-methods/errorResponse.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spinajs/http",
3
- "version": "2.0.184",
3
+ "version": "2.0.186",
4
4
  "description": "framework HTTP module base on express.js",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -61,16 +61,16 @@
61
61
  "cpx": "1.5.0"
62
62
  },
63
63
  "dependencies": {
64
- "@spinajs/configuration": "^2.0.184",
65
- "@spinajs/di": "^2.0.184",
66
- "@spinajs/exceptions": "^2.0.184",
67
- "@spinajs/fs": "^2.0.184",
68
- "@spinajs/log": "^2.0.184",
69
- "@spinajs/reflection": "^2.0.184",
70
- "@spinajs/templates": "^2.0.184",
71
- "@spinajs/validation": "^2.0.184",
72
- "@spinajs/templates-pug": "^2.0.184",
73
- "@spinajs/util": "^2.0.184",
64
+ "@spinajs/configuration": "^2.0.186",
65
+ "@spinajs/di": "^2.0.186",
66
+ "@spinajs/exceptions": "^2.0.186",
67
+ "@spinajs/fs": "^2.0.186",
68
+ "@spinajs/log": "^2.0.186",
69
+ "@spinajs/reflection": "^2.0.186",
70
+ "@spinajs/templates": "^2.0.186",
71
+ "@spinajs/validation": "^2.0.186",
72
+ "@spinajs/templates-pug": "^2.0.186",
73
+ "@spinajs/util": "^2.0.186",
74
74
  "compression": "^1.7.4",
75
75
  "cookie-parser": "^1.4.6",
76
76
  "cookie-signature": "^1.2.0",
@@ -1,20 +0,0 @@
1
- /// <reference types="qs" />
2
- import * as express from 'express';
3
- import { ICookieOptions, Response } from '../interfaces.js';
4
- /**
5
- * Simpel wrapper for coockie response for api consistency.
6
- * It also signs cookie with coockie-secure
7
- *
8
- * @param cookieLifetime - cookie max age in seconds
9
- */
10
- export declare class CookieResponse extends Response {
11
- protected name: string;
12
- protected coockieValue: string;
13
- protected cookieLifetime: number;
14
- protected signed?: boolean;
15
- protected data?: any;
16
- protected options?: ICookieOptions;
17
- constructor(name: string, coockieValue: string, cookieLifetime: number, signed?: boolean, data?: any, options?: ICookieOptions);
18
- 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>;
19
- }
20
- //# sourceMappingURL=cookieResponse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cookieResponse.d.ts","sourceRoot":"","sources":["../../../src/response-methods/cookieResponse.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAKnC,OAAO,EAAoB,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG9E;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC9B,SAAS,CAAC,IAAI,EAAE,MAAM;IAAE,SAAS,CAAC,YAAY,EAAE,MAAM;IAAE,SAAS,CAAC,cAAc,EAAE,MAAM;IAAE,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO;IAAE,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG;IAAE,SAAS,CAAC,OAAO,CAAC,EAAE,cAAc;gBAApK,IAAI,EAAE,MAAM,EAAY,YAAY,EAAE,MAAM,EAAY,cAAc,EAAE,MAAM,EAAY,MAAM,CAAC,EAAE,OAAO,EAAY,IAAI,CAAC,EAAE,GAAG,EAAY,OAAO,CAAC,EAAE,cAAc;IAI7K,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ;CA2BlE"}
@@ -1,74 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.CookieResponse = void 0;
27
- const responses_js_1 = require("../responses.js");
28
- const configuration_1 = require("@spinajs/configuration");
29
- const di_1 = require("@spinajs/di");
30
- const cs = __importStar(require("cookie-signature"));
31
- const interfaces_js_1 = require("../interfaces.js");
32
- /**
33
- * Simpel wrapper for coockie response for api consistency.
34
- * It also signs cookie with coockie-secure
35
- *
36
- * @param cookieLifetime - cookie max age in seconds
37
- */
38
- class CookieResponse extends interfaces_js_1.Response {
39
- constructor(name, coockieValue, cookieLifetime, signed, data, options) {
40
- super(coockieValue);
41
- this.name = name;
42
- this.coockieValue = coockieValue;
43
- this.cookieLifetime = cookieLifetime;
44
- this.signed = signed;
45
- this.data = data;
46
- this.options = options;
47
- }
48
- async execute(_req, res) {
49
- const cfg = di_1.DI.get(configuration_1.Configuration);
50
- const opt = cfg.get('http.cookie.options', {});
51
- if (this.options) {
52
- Object.assign(opt, this.options);
53
- }
54
- if (this.cookieLifetime) {
55
- Object.assign(opt, { maxAge: this.cookieLifetime * 1000 });
56
- }
57
- if (!this.responseData) {
58
- res.clearCookie(this.name, opt);
59
- }
60
- else {
61
- if (this.signed) {
62
- const secureKey = cfg.get('http.cookie.secret');
63
- const signed = cs.sign(this.responseData, secureKey);
64
- res.cookie(this.name, signed, opt);
65
- }
66
- else {
67
- res.cookie(this.name, this.responseData, opt);
68
- }
69
- }
70
- return await (0, responses_js_1.httpResponse)(this.data, interfaces_js_1.HTTP_STATUS_CODE.OK, 'responses/ok');
71
- }
72
- }
73
- exports.CookieResponse = CookieResponse;
74
- //# sourceMappingURL=cookieResponse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cookieResponse.js","sourceRoot":"","sources":["../../../src/response-methods/cookieResponse.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAA+C;AAC/C,0DAAuD;AACvD,oCAAiC;AACjC,qDAAuC;AACvC,oDAA8E;AAG9E;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,wBAAQ;IAC1C,YAAsB,IAAY,EAAY,YAAoB,EAAY,cAAsB,EAAY,MAAgB,EAAY,IAAU,EAAY,OAAwB;QACxL,KAAK,CAAC,YAAY,CAAC,CAAC;QADA,SAAI,GAAJ,IAAI,CAAQ;QAAY,iBAAY,GAAZ,YAAY,CAAQ;QAAY,mBAAc,GAAd,cAAc,CAAQ;QAAY,WAAM,GAAN,MAAM,CAAU;QAAY,SAAI,GAAJ,IAAI,CAAM;QAAY,YAAO,GAAP,OAAO,CAAiB;IAE1L,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,GAAqB;QAC/D,MAAM,GAAG,GAAkB,OAAE,CAAC,GAAG,CAAC,6BAAa,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAgB,qBAAqB,EAAE,EAAE,CAAC,CAAC;QAE9D,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SAClC;QAED,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,EAAE,CAAC,CAAC;SAC5D;QAED,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACtB,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,GAAoB,CAAC,CAAC;SAClD;aAAM;YACL,IAAI,IAAI,CAAC,MAAM,EAAE;gBACf,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,CAAS,oBAAoB,CAAC,CAAC;gBACxD,MAAM,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;gBAErD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAU,CAAC,CAAC;aAC3C;iBAAM;gBACL,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,GAAU,CAAC,CAAC;aACtD;SACF;QAED,OAAO,MAAM,IAAA,2BAAY,EAAC,IAAI,CAAC,IAAI,EAAE,gCAAgB,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAC5E,CAAC;CACF;AAhCD,wCAgCC"}
@@ -1,8 +0,0 @@
1
- /// <reference types="qs" />
2
- import * as express from 'express';
3
- import { Response } from '../interfaces.js';
4
- export declare class ErrorResponse extends Response {
5
- constructor(error: any);
6
- 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>;
7
- }
8
- //# sourceMappingURL=errorResponse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errorResponse.d.ts","sourceRoot":"","sources":["../../../src/response-methods/errorResponse.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAoB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAM9D,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,KAAK,EAAE,GAAG;IAST,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ;CAGnE"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ErrorResponse = void 0;
7
- const interfaces_js_1 = require("../interfaces.js");
8
- const responses_js_1 = require("../responses.js");
9
- const lodash_1 = __importDefault(require("lodash"));
10
- const di_1 = require("@spinajs/di");
11
- const configuration_1 = require("@spinajs/configuration");
12
- class ErrorResponse extends interfaces_js_1.Response {
13
- constructor(error) {
14
- super(error);
15
- const isDev = di_1.DI.get(configuration_1.Configuration).get('configuration.isDevelopment');
16
- if (!isDev) {
17
- this.responseData = lodash_1.default.omit(this.responseData, ['stack']);
18
- }
19
- }
20
- async execute(_req, _res) {
21
- return await (0, responses_js_1.httpResponse)(this.responseData, interfaces_js_1.HTTP_STATUS_CODE.BAD_REQUEST, 'badRequest.pug');
22
- }
23
- }
24
- exports.ErrorResponse = ErrorResponse;
25
- //# sourceMappingURL=errorResponse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errorResponse.js","sourceRoot":"","sources":["../../../src/response-methods/errorResponse.ts"],"names":[],"mappings":";;;;;;AACA,oDAA8D;AAC9D,kDAA+C;AAC/C,oDAAuB;AACvB,oCAAiC;AACjC,0DAAuD;AAEvD,MAAa,aAAc,SAAQ,wBAAQ;IACzC,YAAY,KAAU;QACpB,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,MAAM,KAAK,GAAG,OAAE,CAAC,GAAG,CAAC,6BAAa,CAAC,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QACvE,IAAI,CAAC,KAAK,EAAE;YACV,IAAI,CAAC,YAAY,GAAG,gBAAC,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;SAC1D;IACH,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,2BAAY,EAAC,IAAI,CAAC,YAAY,EAAE,gCAAgB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IAC/F,CAAC;CACF;AAbD,sCAaC"}
@@ -1,20 +0,0 @@
1
- /// <reference types="qs" />
2
- import * as express from 'express';
3
- import { ICookieOptions, Response } from '../interfaces.js';
4
- /**
5
- * Simpel wrapper for coockie response for api consistency.
6
- * It also signs cookie with coockie-secure
7
- *
8
- * @param cookieLifetime - cookie max age in seconds
9
- */
10
- export declare class CookieResponse extends Response {
11
- protected name: string;
12
- protected coockieValue: string;
13
- protected cookieLifetime: number;
14
- protected signed?: boolean;
15
- protected data?: any;
16
- protected options?: ICookieOptions;
17
- constructor(name: string, coockieValue: string, cookieLifetime: number, signed?: boolean, data?: any, options?: ICookieOptions);
18
- 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>;
19
- }
20
- //# sourceMappingURL=cookieResponse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cookieResponse.d.ts","sourceRoot":"","sources":["../../../src/response-methods/cookieResponse.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAKnC,OAAO,EAAoB,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG9E;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC9B,SAAS,CAAC,IAAI,EAAE,MAAM;IAAE,SAAS,CAAC,YAAY,EAAE,MAAM;IAAE,SAAS,CAAC,cAAc,EAAE,MAAM;IAAE,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO;IAAE,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG;IAAE,SAAS,CAAC,OAAO,CAAC,EAAE,cAAc;gBAApK,IAAI,EAAE,MAAM,EAAY,YAAY,EAAE,MAAM,EAAY,cAAc,EAAE,MAAM,EAAY,MAAM,CAAC,EAAE,OAAO,EAAY,IAAI,CAAC,EAAE,GAAG,EAAY,OAAO,CAAC,EAAE,cAAc;IAI7K,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ;CA2BlE"}
@@ -1,47 +0,0 @@
1
- import { httpResponse } from '../responses.js';
2
- import { Configuration } from '@spinajs/configuration';
3
- import { DI } from '@spinajs/di';
4
- import * as cs from 'cookie-signature';
5
- import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
6
- /**
7
- * Simpel wrapper for coockie response for api consistency.
8
- * It also signs cookie with coockie-secure
9
- *
10
- * @param cookieLifetime - cookie max age in seconds
11
- */
12
- export class CookieResponse extends Response {
13
- constructor(name, coockieValue, cookieLifetime, signed, data, options) {
14
- super(coockieValue);
15
- this.name = name;
16
- this.coockieValue = coockieValue;
17
- this.cookieLifetime = cookieLifetime;
18
- this.signed = signed;
19
- this.data = data;
20
- this.options = options;
21
- }
22
- async execute(_req, res) {
23
- const cfg = DI.get(Configuration);
24
- const opt = cfg.get('http.cookie.options', {});
25
- if (this.options) {
26
- Object.assign(opt, this.options);
27
- }
28
- if (this.cookieLifetime) {
29
- Object.assign(opt, { maxAge: this.cookieLifetime * 1000 });
30
- }
31
- if (!this.responseData) {
32
- res.clearCookie(this.name, opt);
33
- }
34
- else {
35
- if (this.signed) {
36
- const secureKey = cfg.get('http.cookie.secret');
37
- const signed = cs.sign(this.responseData, secureKey);
38
- res.cookie(this.name, signed, opt);
39
- }
40
- else {
41
- res.cookie(this.name, this.responseData, opt);
42
- }
43
- }
44
- return await httpResponse(this.data, HTTP_STATUS_CODE.OK, 'responses/ok');
45
- }
46
- }
47
- //# sourceMappingURL=cookieResponse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cookieResponse.js","sourceRoot":"","sources":["../../../src/response-methods/cookieResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAkB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG9E;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAC1C,YAAsB,IAAY,EAAY,YAAoB,EAAY,cAAsB,EAAY,MAAgB,EAAY,IAAU,EAAY,OAAwB;QACxL,KAAK,CAAC,YAAY,CAAC,CAAC;QADA,SAAI,GAAJ,IAAI,CAAQ;QAAY,iBAAY,GAAZ,YAAY,CAAQ;QAAY,mBAAc,GAAd,cAAc,CAAQ;QAAY,WAAM,GAAN,MAAM,CAAU;QAAY,SAAI,GAAJ,IAAI,CAAM;QAAY,YAAO,GAAP,OAAO,CAAiB;IAE1L,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,GAAqB;QAC/D,MAAM,GAAG,GAAkB,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAgB,qBAAqB,EAAE,EAAE,CAAC,CAAC;QAE9D,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SAClC;QAED,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,EAAE,CAAC,CAAC;SAC5D;QAED,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACtB,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,GAAoB,CAAC,CAAC;SAClD;aAAM;YACL,IAAI,IAAI,CAAC,MAAM,EAAE;gBACf,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,CAAS,oBAAoB,CAAC,CAAC;gBACxD,MAAM,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;gBAErD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAU,CAAC,CAAC;aAC3C;iBAAM;gBACL,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,GAAU,CAAC,CAAC;aACtD;SACF;QAED,OAAO,MAAM,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAC5E,CAAC;CACF"}
@@ -1,8 +0,0 @@
1
- /// <reference types="qs" />
2
- import * as express from 'express';
3
- import { Response } from '../interfaces.js';
4
- export declare class ErrorResponse extends Response {
5
- constructor(error: any);
6
- 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>;
7
- }
8
- //# sourceMappingURL=errorResponse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errorResponse.d.ts","sourceRoot":"","sources":["../../../src/response-methods/errorResponse.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAoB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAM9D,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,KAAK,EAAE,GAAG;IAST,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ;CAGnE"}
@@ -1,18 +0,0 @@
1
- import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
2
- import { httpResponse } from '../responses.js';
3
- import _ from 'lodash';
4
- import { DI } from '@spinajs/di';
5
- import { Configuration } from '@spinajs/configuration';
6
- export class ErrorResponse extends Response {
7
- constructor(error) {
8
- super(error);
9
- const isDev = DI.get(Configuration).get('configuration.isDevelopment');
10
- if (!isDev) {
11
- this.responseData = _.omit(this.responseData, ['stack']);
12
- }
13
- }
14
- async execute(_req, _res) {
15
- return await httpResponse(this.responseData, HTTP_STATUS_CODE.BAD_REQUEST, 'badRequest.pug');
16
- }
17
- }
18
- //# sourceMappingURL=errorResponse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errorResponse.js","sourceRoot":"","sources":["../../../src/response-methods/errorResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,OAAO,aAAc,SAAQ,QAAQ;IACzC,YAAY,KAAU;QACpB,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,MAAM,KAAK,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QACvE,IAAI,CAAC,KAAK,EAAE;YACV,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;SAC1D;IACH,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IAC/F,CAAC;CACF"}