@spinajs/http 2.0.25 → 2.0.44

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 (65) hide show
  1. package/lib/config/http.js +1 -1
  2. package/lib/config/http.js.map +1 -1
  3. package/lib/controllers.d.ts +5 -5
  4. package/lib/controllers.js +28 -12
  5. package/lib/controllers.js.map +1 -1
  6. package/lib/decorators.d.ts +2 -2
  7. package/lib/decorators.js.map +1 -1
  8. package/lib/interfaces.d.ts +41 -8
  9. package/lib/interfaces.js +10 -4
  10. package/lib/interfaces.js.map +1 -1
  11. package/lib/response-methods/badRequest.d.ts +1 -1
  12. package/lib/response-methods/badRequest.js +1 -1
  13. package/lib/response-methods/badRequest.js.map +1 -1
  14. package/lib/response-methods/conflict.d.ts +1 -1
  15. package/lib/response-methods/conflict.js +1 -1
  16. package/lib/response-methods/conflict.js.map +1 -1
  17. package/lib/response-methods/cookieResponse.d.ts +1 -2
  18. package/lib/response-methods/cookieResponse.js +1 -1
  19. package/lib/response-methods/cookieResponse.js.map +1 -1
  20. package/lib/response-methods/created.d.ts +1 -1
  21. package/lib/response-methods/created.js +1 -1
  22. package/lib/response-methods/created.js.map +1 -1
  23. package/lib/response-methods/file.d.ts +12 -8
  24. package/lib/response-methods/file.js +85 -35
  25. package/lib/response-methods/file.js.map +1 -1
  26. package/lib/response-methods/forbidden.d.ts +1 -1
  27. package/lib/response-methods/forbidden.js +1 -1
  28. package/lib/response-methods/forbidden.js.map +1 -1
  29. package/lib/response-methods/noContent.d.ts +1 -1
  30. package/lib/response-methods/noContent.js +1 -1
  31. package/lib/response-methods/noContent.js.map +1 -1
  32. package/lib/response-methods/notAllowed.d.ts +1 -1
  33. package/lib/response-methods/notAllowed.js +1 -1
  34. package/lib/response-methods/notAllowed.js.map +1 -1
  35. package/lib/response-methods/notFound.d.ts +1 -1
  36. package/lib/response-methods/notFound.js +1 -1
  37. package/lib/response-methods/notFound.js.map +1 -1
  38. package/lib/response-methods/ok.d.ts +1 -1
  39. package/lib/response-methods/ok.js +1 -1
  40. package/lib/response-methods/ok.js.map +1 -1
  41. package/lib/response-methods/pug.d.ts +2 -3
  42. package/lib/response-methods/pug.js +4 -4
  43. package/lib/response-methods/pug.js.map +1 -1
  44. package/lib/response-methods/redirect.d.ts +1 -1
  45. package/lib/response-methods/redirect.js +2 -2
  46. package/lib/response-methods/redirect.js.map +1 -1
  47. package/lib/response-methods/serverError.d.ts +1 -1
  48. package/lib/response-methods/serverError.js +1 -1
  49. package/lib/response-methods/serverError.js.map +1 -1
  50. package/lib/response-methods/unauthorized.d.ts +1 -1
  51. package/lib/response-methods/unauthorized.js +1 -1
  52. package/lib/response-methods/unauthorized.js.map +1 -1
  53. package/lib/responses.d.ts +1 -7
  54. package/lib/responses.js +22 -88
  55. package/lib/responses.js.map +1 -1
  56. package/lib/route-args/FromDi.d.ts +3 -3
  57. package/lib/route-args/FromDi.js +2 -2
  58. package/lib/route-args/FromDi.js.map +1 -1
  59. package/lib/route-args/FromForm.d.ts +8 -1
  60. package/lib/route-args/FromForm.js +54 -58
  61. package/lib/route-args/FromForm.js.map +1 -1
  62. package/lib/server.d.ts +4 -3
  63. package/lib/server.js +5 -2
  64. package/lib/server.js.map +1 -1
  65. package/package.json +15 -12
@@ -22,67 +22,117 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.JsonFileResponse = exports.FileResponse = void 0;
26
+ exports.JsonFileResponse = exports.FileResponse = exports.ZipResponse = void 0;
27
+ const di_1 = require("@spinajs/di");
30
28
  const exceptions_1 = require("@spinajs/exceptions");
31
- const fs = __importStar(require("fs"));
32
29
  const _ = __importStar(require("lodash"));
33
30
  const mime_1 = require("mime");
34
- const responses_1 = require("../responses");
35
- const tempfile_1 = __importDefault(require("tempfile"));
36
- class FileResponse extends responses_1.Response {
31
+ const interfaces_1 = require("./../interfaces");
32
+ class ZipResponse extends interfaces_1.Response {
37
33
  /**
38
- * Sends file to client at given path & filename. If file exists
34
+ * Sends zipped to client at given path & filename. If file exists
39
35
  * it will send file with 200 OK, if not exists 404 NOT FOUND
40
- * @param path - server full path to file
41
- * @param filename - real filename send to client
42
- * @param mimeType - optional mimetype. If not set, server will try to guess.
43
36
  */
44
- constructor(path, filename, mimeType) {
37
+ constructor(Options) {
38
+ var _a;
45
39
  super(null);
46
- this.mimeType = mimeType ? mimeType : (0, mime_1.getType)(filename);
47
- this.filename = filename;
48
- this.path = path;
49
- if (!fs.existsSync(path)) {
50
- throw new exceptions_1.ResourceNotFound(`File ${path} not exists`);
40
+ this.Options = Options;
41
+ this.Options.mimeType = (_a = Options.mimeType) !== null && _a !== void 0 ? _a : (0, mime_1.getType)(Options.filename);
42
+ }
43
+ async execute(_req, res) {
44
+ const provider = await di_1.DI.resolve('__file_provider__', [this.Options.provider]);
45
+ const exists = await provider.exists(this.Options.path);
46
+ if (!exists) {
47
+ throw new exceptions_1.ResourceNotFound(`File ${this.Options.path} not exists`);
51
48
  }
49
+ const file = (await provider.zip(this.Options.path)).asFilePath();
50
+ return new Promise((resolve, reject) => {
51
+ res.download(file, this.Options.filename, (err) => {
52
+ provider
53
+ .unlink(this.Options.path, true)
54
+ .then(() => {
55
+ return provider.unlink(file);
56
+ })
57
+ .then(() => {
58
+ if (!_.isNil(err)) {
59
+ reject(err);
60
+ }
61
+ else {
62
+ resolve();
63
+ }
64
+ })
65
+ .catch((err) => {
66
+ reject(err);
67
+ });
68
+ });
69
+ });
70
+ }
71
+ }
72
+ exports.ZipResponse = ZipResponse;
73
+ class FileResponse extends interfaces_1.Response {
74
+ /**
75
+ * Sends file to client at given path & filename. If file exists
76
+ * it will send file with 200 OK, if not exists 404 NOT FOUND
77
+ */
78
+ constructor(Options) {
79
+ var _a;
80
+ super(null);
81
+ this.Options = Options;
82
+ this.Options.mimeType = (_a = Options.mimeType) !== null && _a !== void 0 ? _a : (0, mime_1.getType)(Options.filename);
52
83
  }
53
84
  async execute(_req, res) {
85
+ const provider = await di_1.DI.resolve('__file_provider__', [this.Options.provider]);
86
+ const exists = await provider.exists(this.Options.path);
87
+ if (!exists) {
88
+ throw new exceptions_1.ResourceNotFound(`File ${this.Options.path} not exists`);
89
+ }
90
+ const file = await provider.download(this.Options.path);
54
91
  return new Promise((resolve, reject) => {
55
- res.download(this.path, this.filename, (err) => {
56
- if (!_.isNil(err)) {
92
+ res.download(file, this.Options.filename, (err) => {
93
+ provider
94
+ .unlink(this.Options.path, true)
95
+ .then(() => {
96
+ if (!_.isNil(err)) {
97
+ reject(err);
98
+ }
99
+ else {
100
+ resolve();
101
+ }
102
+ })
103
+ .catch((err) => {
57
104
  reject(err);
58
- }
59
- else {
60
- resolve();
61
- }
105
+ });
62
106
  });
63
107
  });
64
108
  }
65
109
  }
66
110
  exports.FileResponse = FileResponse;
67
- class JsonFileResponse extends responses_1.Response {
111
+ class JsonFileResponse extends interfaces_1.Response {
68
112
  constructor(data, filename) {
69
113
  super(null);
70
114
  this.data = data;
71
115
  this.filename = filename;
72
116
  }
73
117
  async execute(_req, res) {
74
- const tempPath = (0, tempfile_1.default)('.json');
75
- const file = await fs.promises.open(tempPath, 'w');
76
- await file.writeFile(JSON.stringify(this.data));
118
+ const provider = await di_1.DI.resolve('__file_provider__', ['fs-temp']);
119
+ const tmpPath = provider.tmppath();
120
+ provider.write(tmpPath, JSON.stringify(this.data));
77
121
  return new Promise((resolve, reject) => {
78
- res.download(tempPath, this.filename, (err) => {
79
- if (err) {
122
+ res.download(tmpPath, this.filename, (err) => {
123
+ provider
124
+ .unlink(tmpPath)
125
+ .then(() => {
126
+ if (err) {
127
+ reject(err);
128
+ }
129
+ else {
130
+ resolve();
131
+ }
132
+ })
133
+ .catch((err) => {
80
134
  reject(err);
81
- }
82
- else {
83
- resolve();
84
- }
85
- fs.unlink(tempPath, null);
135
+ });
86
136
  });
87
137
  });
88
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/response-methods/file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAuD;AAEvD,uCAAyB;AACzB,0CAA4B;AAC5B,+BAA+B;AAC/B,4CAAwC;AACxC,wDAAgC;AAEhC,MAAa,YAAa,SAAQ,oBAAQ;IAKxC;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,QAAgB,EAAE,QAAiB;QAC3D,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YACxB,MAAM,IAAI,6BAAgB,CAAC,QAAQ,IAAI,aAAa,CAAC,CAAC;SACvD;IACH,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,GAAqB;QAC/D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAU,EAAE,EAAE;gBACpD,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;oBACjB,MAAM,CAAC,GAAG,CAAC,CAAC;iBACb;qBAAM;oBACL,OAAO,EAAE,CAAC;iBACX;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAnCD,oCAmCC;AAED,MAAa,gBAAiB,SAAQ,oBAAQ;IAC5C,YAAsB,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C,CAAC,CAAC;IACL,CAAC;CACF;AA3BD,4CA2BC"}
@@ -1,5 +1,5 @@
1
1
  import * as express from 'express';
2
- import { Response } from '../responses';
2
+ import { Response } from '../interfaces';
3
3
  /**
4
4
  * Internall response function.
5
5
  * Returns HTTP 403 FORBIDDEN ERROR
@@ -8,7 +8,7 @@ const responses_1 = require("../responses");
8
8
  * Returns HTTP 403 FORBIDDEN ERROR
9
9
  * @param err - error to send
10
10
  */
11
- class Forbidden extends responses_1.Response {
11
+ class Forbidden extends interfaces_1.Response {
12
12
  constructor(data) {
13
13
  super(data);
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"forbidden.js","sourceRoot":"","sources":["../../src/response-methods/forbidden.ts"],"names":[],"mappings":";;;AACA,8CAAiD;AACjD,4CAAsD;AAEtD;;;;GAIG;AAEH,MAAa,SAAU,SAAQ,oBAAQ;IACrC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;IAClG,CAAC;CACF;AARD,8BAQC"}
1
+ {"version":3,"file":"forbidden.js","sourceRoot":"","sources":["../../src/response-methods/forbidden.ts"],"names":[],"mappings":";;;AACA,8CAA2D;AAC3D,4CAA4C;AAE5C;;;;GAIG;AAEH,MAAa,SAAU,SAAQ,qBAAQ;IACrC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;IAClG,CAAC;CACF;AARD,8BAQC"}
@@ -1,5 +1,5 @@
1
1
  import * as express from 'express';
2
- import { Response } from '../responses';
2
+ import { Response } from '../interfaces';
3
3
  /**
4
4
  * Internall response function.
5
5
  * Returns HTTP 204 NO CONTENT
@@ -8,7 +8,7 @@ const responses_1 = require("../responses");
8
8
  * Returns HTTP 204 NO CONTENT
9
9
  * @param err - error to send
10
10
  */
11
- class NoContent extends responses_1.Response {
11
+ class NoContent extends interfaces_1.Response {
12
12
  constructor(data) {
13
13
  super(data);
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"noContent.js","sourceRoot":"","sources":["../../src/response-methods/noContent.ts"],"names":[],"mappings":";;;AACA,8CAAiD;AACjD,4CAAsD;AAEtD;;;;GAIG;AACH,MAAa,SAAU,SAAQ,oBAAQ;IACrC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC;IACnG,CAAC;CACF;AARD,8BAQC"}
1
+ {"version":3,"file":"noContent.js","sourceRoot":"","sources":["../../src/response-methods/noContent.ts"],"names":[],"mappings":";;;AACA,8CAA2D;AAC3D,4CAA4C;AAE5C;;;;GAIG;AACH,MAAa,SAAU,SAAQ,qBAAQ;IACrC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC;IACnG,CAAC;CACF;AARD,8BAQC"}
@@ -1,5 +1,5 @@
1
1
  import * as express from 'express';
2
- import { Response } from '../responses';
2
+ import { Response } from '../interfaces';
3
3
  /**
4
4
  * Internall response function.
5
5
  * Returns HTTP 403 FORBIDDEN ERROR
@@ -8,7 +8,7 @@ const responses_1 = require("../responses");
8
8
  * Returns HTTP 403 FORBIDDEN ERROR
9
9
  * @param err - error to send
10
10
  */
11
- class NotAllowed extends responses_1.Response {
11
+ class NotAllowed extends interfaces_1.Response {
12
12
  constructor(data) {
13
13
  super(data);
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"notAllowed.js","sourceRoot":"","sources":["../../src/response-methods/notAllowed.ts"],"names":[],"mappings":";;;AACA,8CAAiD;AACjD,4CAAsD;AAEtD;;;;GAIG;AAEH,MAAa,UAAW,SAAQ,oBAAQ;IACtC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;IACtG,CAAC;CACF;AARD,gCAQC"}
1
+ {"version":3,"file":"notAllowed.js","sourceRoot":"","sources":["../../src/response-methods/notAllowed.ts"],"names":[],"mappings":";;;AACA,8CAA2D;AAC3D,4CAA4C;AAE5C;;;;GAIG;AAEH,MAAa,UAAW,SAAQ,qBAAQ;IACtC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;IACtG,CAAC;CACF;AARD,gCAQC"}
@@ -1,5 +1,5 @@
1
1
  import * as express from 'express';
2
- import { Response } from '../responses';
2
+ import { Response } from '../interfaces';
3
3
  /**
4
4
  * Internall response function.
5
5
  * Returns HTTP 404 NOT FOUND ERROR
@@ -8,7 +8,7 @@ const responses_1 = require("../responses");
8
8
  * Returns HTTP 404 NOT FOUND ERROR
9
9
  * @param err - error to send
10
10
  */
11
- class NotFound extends responses_1.Response {
11
+ class NotFound extends interfaces_1.Response {
12
12
  constructor(data) {
13
13
  super(data);
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"notFound.js","sourceRoot":"","sources":["../../src/response-methods/notFound.ts"],"names":[],"mappings":";;;AACA,8CAAiD;AACjD,4CAAsD;AAEtD;;;;GAIG;AACH,MAAa,QAAS,SAAQ,oBAAQ;IACpC,YAAY,IAAU;QACpB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;IACjG,CAAC;CACF;AARD,4BAQC"}
1
+ {"version":3,"file":"notFound.js","sourceRoot":"","sources":["../../src/response-methods/notFound.ts"],"names":[],"mappings":";;;AACA,8CAA2D;AAC3D,4CAA4C;AAE5C;;;;GAIG;AACH,MAAa,QAAS,SAAQ,qBAAQ;IACpC,YAAY,IAAU;QACpB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;IACjG,CAAC;CACF;AARD,4BAQC"}
@@ -1,5 +1,5 @@
1
1
  import * as express from 'express';
2
- import { Response } from '../responses';
2
+ import { Response } from '../interfaces';
3
3
  /**
4
4
  * Internall response function.
5
5
  * Returns HTTP 200 OK response with json content
@@ -8,7 +8,7 @@ const responses_1 = require("../responses");
8
8
  * Returns HTTP 200 OK response with json content
9
9
  * @param data - data to send
10
10
  */
11
- class Ok extends responses_1.Response {
11
+ class Ok extends interfaces_1.Response {
12
12
  constructor(data) {
13
13
  super(data);
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ok.js","sourceRoot":"","sources":["../../src/response-methods/ok.ts"],"names":[],"mappings":";;;AACA,8CAAiD;AACjD,4CAAsD;AAEtD;;;;GAIG;AACH,MAAa,EAAG,SAAQ,oBAAQ;IAC9B,YAAY,IAAU;QACpB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IACpF,CAAC;CACF;AARD,gBAQC"}
1
+ {"version":3,"file":"ok.js","sourceRoot":"","sources":["../../src/response-methods/ok.ts"],"names":[],"mappings":";;;AACA,8CAA2D;AAC3D,4CAA4C;AAE5C;;;;GAIG;AACH,MAAa,EAAG,SAAQ,qBAAQ;IAC9B,YAAY,IAAU;QACpB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IACpF,CAAC;CACF;AARD,gBAQC"}
@@ -1,10 +1,9 @@
1
1
  import * as express from 'express';
2
- import { HTTP_STATUS_CODE } from '../interfaces';
3
- import { Response } from '../responses';
2
+ import { HTTP_STATUS_CODE, Response } from '../interfaces';
4
3
  /**
5
4
  * HTML resposne with HTML from pug file
6
5
  */
7
- export declare class PugResponse extends Response {
6
+ export declare class TemplateResponse extends Response {
8
7
  protected file: string;
9
8
  protected status: HTTP_STATUS_CODE;
10
9
  constructor(file: string, model: any, status?: HTTP_STATUS_CODE);
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PugResponse = void 0;
3
+ exports.TemplateResponse = void 0;
4
4
  const interfaces_1 = require("../interfaces");
5
5
  const responses_1 = require("../responses");
6
6
  /**
7
7
  * HTML resposne with HTML from pug file
8
8
  */
9
- class PugResponse extends responses_1.Response {
9
+ class TemplateResponse extends interfaces_1.Response {
10
10
  constructor(file, model, status) {
11
11
  super(model);
12
12
  this.status = null;
@@ -14,8 +14,8 @@ class PugResponse extends responses_1.Response {
14
14
  this.status = status;
15
15
  }
16
16
  async execute(_req, _res) {
17
- return await (0, responses_1.pugResponse)(this.file, this.responseData, this.status ? this.status : interfaces_1.HTTP_STATUS_CODE.OK);
17
+ return await (0, responses_1.htmlResponse)(this.file, this.responseData, this.status ? this.status : interfaces_1.HTTP_STATUS_CODE.OK);
18
18
  }
19
19
  }
20
- exports.PugResponse = PugResponse;
20
+ exports.TemplateResponse = TemplateResponse;
21
21
  //# sourceMappingURL=pug.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pug.js","sourceRoot":"","sources":["../../src/response-methods/pug.ts"],"names":[],"mappings":";;;AACA,8CAAiD;AACjD,4CAAqD;AAErD;;GAEG;AACH,MAAa,WAAY,SAAQ,oBAAQ;IAIvC,YAAY,IAAY,EAAE,KAAU,EAAE,MAAyB;QAC7D,KAAK,CAAC,KAAK,CAAC,CAAC;QAHL,WAAM,GAAqB,IAAI,CAAC;QAKxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,uBAAW,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,6BAAgB,CAAC,EAAE,CAAC,CAAC;IAC1G,CAAC;CACF;AAdD,kCAcC"}
1
+ {"version":3,"file":"pug.js","sourceRoot":"","sources":["../../src/response-methods/pug.ts"],"names":[],"mappings":";;;AACA,8CAA2D;AAC3D,4CAA4C;AAE5C;;GAEG;AACH,MAAa,gBAAiB,SAAQ,qBAAQ;IAI5C,YAAY,IAAY,EAAE,KAAU,EAAE,MAAyB;QAC7D,KAAK,CAAC,KAAK,CAAC,CAAC;QAHL,WAAM,GAAqB,IAAI,CAAC;QAKxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,6BAAgB,CAAC,EAAE,CAAC,CAAC;IAC3G,CAAC;CACF;AAdD,4CAcC"}
@@ -1,5 +1,5 @@
1
1
  import * as express from 'express';
2
- import { Response } from '../responses';
2
+ import { Response } from '../interfaces';
3
3
  /**
4
4
  * Redirects to another route ( simple alias for request.redirect for api consistency)
5
5
  *
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Redirect = void 0;
4
- const responses_1 = require("../responses");
4
+ const interfaces_1 = require("../interfaces");
5
5
  /**
6
6
  * Redirects to another route ( simple alias for request.redirect for api consistency)
7
7
  *
8
8
  * @param url - url path to another location
9
9
  */
10
- class Redirect extends responses_1.Response {
10
+ class Redirect extends interfaces_1.Response {
11
11
  constructor(url) {
12
12
  super(null);
13
13
  this.url = url;
@@ -1 +1 @@
1
- {"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../src/response-methods/redirect.ts"],"names":[],"mappings":";;;AACA,4CAAwC;AAExC;;;;GAIG;AACH,MAAa,QAAS,SAAQ,oBAAQ;IAGpC,YAAY,GAAQ;QAClB,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,GAAqB;QAC/D,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;CACF;AAZD,4BAYC"}
1
+ {"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../src/response-methods/redirect.ts"],"names":[],"mappings":";;;AACA,8CAAyC;AAEzC;;;;GAIG;AACH,MAAa,QAAS,SAAQ,qBAAQ;IAGpC,YAAY,GAAQ;QAClB,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,GAAqB;QAC/D,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;CACF;AAZD,4BAYC"}
@@ -1,5 +1,5 @@
1
1
  import * as express from 'express';
2
- import { Response } from '../responses';
2
+ import { Response } from '../interfaces';
3
3
  /**
4
4
  * Internall response function.
5
5
  * Returns HTTP 500 INTERNAL SERVER ERROR
@@ -8,7 +8,7 @@ const responses_1 = require("../responses");
8
8
  * Returns HTTP 500 INTERNAL SERVER ERROR
9
9
  * @param err - error to send
10
10
  */
11
- class ServerError extends responses_1.Response {
11
+ class ServerError extends interfaces_1.Response {
12
12
  constructor(data) {
13
13
  super(data);
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"serverError.js","sourceRoot":"","sources":["../../src/response-methods/serverError.ts"],"names":[],"mappings":";;;AACA,8CAAiD;AACjD,4CAAsD;AAEtD;;;;GAIG;AAEH,MAAa,WAAY,SAAQ,oBAAQ;IACvC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,EAAE,6BAAgB,CAAC,cAAc,EAAE,uBAAuB,CAAC,CAAC;IACpH,CAAC;CACF;AARD,kCAQC"}
1
+ {"version":3,"file":"serverError.js","sourceRoot":"","sources":["../../src/response-methods/serverError.ts"],"names":[],"mappings":";;;AACA,8CAA2D;AAC3D,4CAA4C;AAE5C;;;;GAIG;AAEH,MAAa,WAAY,SAAQ,qBAAQ;IACvC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,EAAE,6BAAgB,CAAC,cAAc,EAAE,uBAAuB,CAAC,CAAC;IACpH,CAAC;CACF;AARD,kCAQC"}
@@ -1,5 +1,5 @@
1
1
  import * as express from 'express';
2
- import { Response } from '../responses';
2
+ import { Response } from '../interfaces';
3
3
  /**
4
4
  * Internall response function.
5
5
  * Returns HTTP 401 UNAHTORIZED response with json content
@@ -8,7 +8,7 @@ const responses_1 = require("../responses");
8
8
  * Returns HTTP 401 UNAHTORIZED response with json content
9
9
  * @param data - data to send
10
10
  */
11
- class Unauthorized extends responses_1.Response {
11
+ class Unauthorized extends interfaces_1.Response {
12
12
  constructor(data) {
13
13
  super(data);
14
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"unauthorized.js","sourceRoot":"","sources":["../../src/response-methods/unauthorized.ts"],"names":[],"mappings":";;;AACA,8CAAiD;AACjD,4CAAsD;AAEtD;;;;GAIG;AAEH,MAAa,YAAa,SAAQ,oBAAQ;IACxC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAAC;IACxG,CAAC;CACF;AARD,oCAQC"}
1
+ {"version":3,"file":"unauthorized.js","sourceRoot":"","sources":["../../src/response-methods/unauthorized.ts"],"names":[],"mappings":";;;AACA,8CAA2D;AAC3D,4CAA4C;AAE5C;;;;GAIG;AAEH,MAAa,YAAa,SAAQ,qBAAQ;IACxC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,IAAA,wBAAY,EAAC,IAAI,CAAC,YAAY,EAAE,6BAAgB,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAAC;IACxG,CAAC;CACF;AARD,oCAQC"}
@@ -1,11 +1,5 @@
1
1
  import * as express from 'express';
2
2
  import { HTTP_STATUS_CODE } from './interfaces';
3
- export declare type ResponseFunction = (req: express.Request, res: express.Response) => void;
4
- export declare abstract class Response {
5
- protected responseData: any;
6
- constructor(responseData: any);
7
- abstract execute(req: express.Request, res: express.Response, next?: express.NextFunction): Promise<ResponseFunction | void>;
8
- }
9
3
  /**
10
4
  * Sends data & sets proper header as json
11
5
  *
@@ -27,7 +21,7 @@ export declare function textResponse(model: any, status?: HTTP_STATUS_CODE): (_r
27
21
  * @param model - data passed to template
28
22
  * @param status - optional status code
29
23
  */
30
- export declare function pugResponse(file: string, model: any, status?: HTTP_STATUS_CODE): (req: express.Request, res: express.Response) => void;
24
+ export declare function htmlResponse(file: string, model: any, status?: HTTP_STATUS_CODE): (req: express.Request, res: express.Response) => void;
31
25
  /**
32
26
  * Default response handling. Checks `Accept` header & matches proper response
33
27
  * For now its supports html & json responses
package/lib/responses.js CHANGED
@@ -23,24 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.httpResponse = exports.pugResponse = exports.textResponse = exports.jsonResponse = exports.Response = void 0;
26
+ exports.httpResponse = exports.htmlResponse = exports.textResponse = exports.jsonResponse = void 0;
27
27
  const interfaces_1 = require("./interfaces");
28
28
  const configuration_1 = require("@spinajs/configuration");
29
29
  const di_1 = require("@spinajs/di");
30
30
  const log_1 = require("@spinajs/log");
31
- const pugTemplate = __importStar(require("pug"));
32
- const path_1 = require("path");
33
- const fs = __importStar(require("fs"));
34
- const _ = __importStar(require("lodash"));
35
- const exceptions_1 = require("@spinajs/exceptions");
36
31
  const randomstring = __importStar(require("randomstring"));
37
- const intl_1 = require("@spinajs/intl");
38
- class Response {
39
- constructor(responseData) {
40
- this.responseData = responseData;
41
- }
42
- }
43
- exports.Response = Response;
32
+ const templates_1 = require("@spinajs/templates");
44
33
  /**
45
34
  * Sends data & sets proper header as json
46
35
  *
@@ -75,38 +64,6 @@ function textResponse(model, status) {
75
64
  };
76
65
  }
77
66
  exports.textResponse = textResponse;
78
- const __translate = (lang) => {
79
- return (text, ...args) => {
80
- const intl = di_1.DI.get(intl_1.Intl);
81
- if (typeof text === 'string') {
82
- return intl.__({
83
- phrase: text,
84
- locale: lang,
85
- }, ...args);
86
- }
87
- return intl.__(text, ...args);
88
- };
89
- };
90
- const __translateNumber = (lang) => {
91
- return (text, count) => {
92
- const intl = di_1.DI.get(intl_1.Intl);
93
- if (typeof text === 'string') {
94
- return intl.__n({
95
- phrase: text,
96
- locale: lang,
97
- }, count);
98
- }
99
- return intl.__n(text, count);
100
- };
101
- };
102
- const __translateL = (text) => {
103
- const intl = di_1.DI.get(intl_1.Intl);
104
- return intl.__l(text);
105
- };
106
- const __translateH = (text) => {
107
- const intl = di_1.DI.get(intl_1.Intl);
108
- return intl.__h(text);
109
- };
110
67
  /**
111
68
  * Sends html response & sets proper header. If template is not avaible, handles proper error rendering.
112
69
  *
@@ -114,7 +71,7 @@ const __translateH = (text) => {
114
71
  * @param model - data passed to template
115
72
  * @param status - optional status code
116
73
  */
117
- function pugResponse(file, model, status) {
74
+ function htmlResponse(file, model, status) {
118
75
  const cfg = di_1.DI.get(configuration_1.Configuration);
119
76
  return (req, res) => {
120
77
  if (!req.accepts('html')) {
@@ -127,52 +84,29 @@ function pugResponse(file, model, status) {
127
84
  return;
128
85
  }
129
86
  res.set('Content-Type', 'text/html');
130
- try {
131
- try {
132
- _render(file, model, status);
133
- }
134
- catch (err) {
135
- const log = di_1.DI.resolve(log_1.Log, ['http']);
136
- log.warn(`Cannot render pug file ${file}, error: ${err.message}:${err.stack}`, err);
137
- // try to render server error response
138
- _render('responses/serverError.pug', { error: err }, interfaces_1.HTTP_STATUS_CODE.INTERNAL_ERROR);
139
- }
140
- }
141
- catch (err) {
87
+ _render(file, model, status).catch((err) => {
142
88
  const log = di_1.DI.resolve(log_1.Log, ['http']);
143
- // final fallback rendering error fails, we render embedded html error page
144
- const ticketNo = randomstring.generate(7);
145
- log.warn(`Cannot render pug file error: ${err.message}, ticket: ${ticketNo}`, err);
146
- res.status(interfaces_1.HTTP_STATUS_CODE.INTERNAL_ERROR);
147
- res.send(cfg.get('http.FatalTemplate').replace('{ticket}', ticketNo));
148
- }
89
+ log.warn(`Cannot render html file ${file}, error: ${err.message}:${err.stack}`, err);
90
+ // try to render server error response
91
+ _render('responses/serverError.pug', { error: err }, interfaces_1.HTTP_STATUS_CODE.INTERNAL_ERROR).catch((err2) => {
92
+ const log = di_1.DI.resolve(log_1.Log, ['http']);
93
+ // final fallback rendering error fails, we render embedded html error page
94
+ const ticketNo = randomstring.generate(7);
95
+ log.warn(`Cannot render pug file error: ${err2.message}, ticket: ${ticketNo}`, err);
96
+ res.status(interfaces_1.HTTP_STATUS_CODE.INTERNAL_ERROR);
97
+ res.send(cfg.get('http.FatalTemplate').replace('{ticket}', ticketNo));
98
+ });
99
+ });
149
100
  function _render(f, m, c) {
150
- const view = getView(f);
151
- const language = req.query[cfg.get('intl.queryParameter')];
152
- const content = pugTemplate.renderFile(view, _.merge(m, {
153
- // add i18n functions as globals
154
- __: __translate(language),
155
- __n: __translateNumber(language),
156
- __l: __translateL,
157
- __h: __translateH,
158
- }));
159
- res.status(c ? c : interfaces_1.HTTP_STATUS_CODE.OK);
160
- res.send(content);
161
- }
162
- function getView(viewFile) {
163
- const views = cfg
164
- .get('system.dirs.views')
165
- .map((p) => (0, path_1.normalize)((0, path_1.join)(p, viewFile)))
166
- .filter((f) => fs.existsSync(f));
167
- if (_.isEmpty(views)) {
168
- throw new exceptions_1.IOFail(`View file ${viewFile} not exists.`);
169
- }
170
- // return last merged path, eg. if application have own view files (override standard views)
171
- return views[views.length - 1];
101
+ const templateEngine = di_1.DI.get(templates_1.Templates);
102
+ return templateEngine.render(f, m).then((content) => {
103
+ res.status(c ? c : interfaces_1.HTTP_STATUS_CODE.OK);
104
+ res.send(content);
105
+ });
172
106
  }
173
107
  };
174
108
  }
175
- exports.pugResponse = pugResponse;
109
+ exports.htmlResponse = htmlResponse;
176
110
  /**
177
111
  * Default response handling. Checks `Accept` header & matches proper response
178
112
  * For now its supports html & json responses
@@ -188,7 +122,7 @@ function httpResponse(model, code, template) {
188
122
  const transformers = di_1.DI.resolve(Array.ofType(interfaces_1.DataTransformer));
189
123
  return (req, res) => {
190
124
  if (req.accepts('html') && (acceptedHeaders & interfaces_1.HttpAcceptHeaders.HTML) === interfaces_1.HttpAcceptHeaders.HTML) {
191
- pugResponse(`${template}.pug`, model, code)(req, res);
125
+ htmlResponse(`${template}.pug`, model, code)(req, res);
192
126
  }
193
127
  else if (req.accepts('json') && (acceptedHeaders & interfaces_1.HttpAcceptHeaders.JSON) === interfaces_1.HttpAcceptHeaders.JSON) {
194
128
  if (req.headers['x-data-transform']) {
@@ -1 +1 @@
1
- {"version":3,"file":"responses.js","sourceRoot":"","sources":["../src/responses.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAAoF;AACpF,0DAAuD;AACvD,oCAAiC;AACjC,sCAAyC;AACzC,iDAAmC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