@spinajs/http 2.0.185 → 2.0.187
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.
- package/lib/cjs/interfaces.d.ts +19 -0
- package/lib/cjs/interfaces.d.ts.map +1 -1
- package/lib/cjs/interfaces.js +4 -0
- package/lib/cjs/interfaces.js.map +1 -1
- package/lib/cjs/middlewares/RequestId.d.ts +1 -1
- package/lib/cjs/middlewares/RequestId.d.ts.map +1 -1
- package/lib/cjs/middlewares/RequestId.js +4 -1
- package/lib/cjs/middlewares/RequestId.js.map +1 -1
- package/lib/cjs/response-methods/badRequest.d.ts +4 -8
- package/lib/cjs/response-methods/badRequest.d.ts.map +1 -1
- package/lib/cjs/response-methods/badRequest.js +18 -10
- package/lib/cjs/response-methods/badRequest.js.map +1 -1
- package/lib/cjs/response-methods/conflict.d.ts +5 -3
- package/lib/cjs/response-methods/conflict.d.ts.map +1 -1
- package/lib/cjs/response-methods/conflict.js +8 -4
- package/lib/cjs/response-methods/conflict.js.map +1 -1
- package/lib/cjs/response-methods/created.d.ts +3 -2
- package/lib/cjs/response-methods/created.d.ts.map +1 -1
- package/lib/cjs/response-methods/created.js +6 -2
- package/lib/cjs/response-methods/created.js.map +1 -1
- package/lib/cjs/response-methods/entityTooLarge.d.ts +3 -2
- package/lib/cjs/response-methods/entityTooLarge.d.ts.map +1 -1
- package/lib/cjs/response-methods/entityTooLarge.js +6 -2
- package/lib/cjs/response-methods/entityTooLarge.js.map +1 -1
- package/lib/cjs/response-methods/file.d.ts +7 -4
- package/lib/cjs/response-methods/file.d.ts.map +1 -1
- package/lib/cjs/response-methods/file.js +13 -3
- package/lib/cjs/response-methods/file.js.map +1 -1
- package/lib/cjs/response-methods/forbidden.d.ts +5 -3
- package/lib/cjs/response-methods/forbidden.d.ts.map +1 -1
- package/lib/cjs/response-methods/forbidden.js +8 -4
- package/lib/cjs/response-methods/forbidden.js.map +1 -1
- package/lib/cjs/response-methods/index.d.ts +0 -1
- package/lib/cjs/response-methods/index.d.ts.map +1 -1
- package/lib/cjs/response-methods/index.js +0 -1
- package/lib/cjs/response-methods/index.js.map +1 -1
- package/lib/cjs/response-methods/noContent.d.ts +5 -3
- package/lib/cjs/response-methods/noContent.d.ts.map +1 -1
- package/lib/cjs/response-methods/noContent.js +8 -4
- package/lib/cjs/response-methods/noContent.js.map +1 -1
- package/lib/cjs/response-methods/notAcceptable.d.ts +5 -3
- package/lib/cjs/response-methods/notAcceptable.d.ts.map +1 -1
- package/lib/cjs/response-methods/notAcceptable.js +8 -4
- package/lib/cjs/response-methods/notAcceptable.js.map +1 -1
- package/lib/cjs/response-methods/notAllowed.d.ts +5 -3
- package/lib/cjs/response-methods/notAllowed.d.ts.map +1 -1
- package/lib/cjs/response-methods/notAllowed.js +8 -4
- package/lib/cjs/response-methods/notAllowed.js.map +1 -1
- package/lib/cjs/response-methods/notFound.d.ts +5 -3
- package/lib/cjs/response-methods/notFound.d.ts.map +1 -1
- package/lib/cjs/response-methods/notFound.js +8 -4
- package/lib/cjs/response-methods/notFound.js.map +1 -1
- package/lib/cjs/response-methods/ok.d.ts +3 -2
- package/lib/cjs/response-methods/ok.d.ts.map +1 -1
- package/lib/cjs/response-methods/ok.js +6 -2
- package/lib/cjs/response-methods/ok.js.map +1 -1
- package/lib/cjs/response-methods/serverError.d.ts +5 -3
- package/lib/cjs/response-methods/serverError.d.ts.map +1 -1
- package/lib/cjs/response-methods/serverError.js +8 -4
- package/lib/cjs/response-methods/serverError.js.map +1 -1
- package/lib/cjs/response-methods/template.d.ts +3 -3
- package/lib/cjs/response-methods/template.d.ts.map +1 -1
- package/lib/cjs/response-methods/template.js +6 -4
- package/lib/cjs/response-methods/template.js.map +1 -1
- package/lib/cjs/response-methods/unauthorized.d.ts +5 -3
- package/lib/cjs/response-methods/unauthorized.d.ts.map +1 -1
- package/lib/cjs/response-methods/unauthorized.js +8 -4
- package/lib/cjs/response-methods/unauthorized.js.map +1 -1
- package/lib/cjs/response-methods/validationError.d.ts +5 -3
- package/lib/cjs/response-methods/validationError.d.ts.map +1 -1
- package/lib/cjs/response-methods/validationError.js +8 -4
- package/lib/cjs/response-methods/validationError.js.map +1 -1
- package/lib/cjs/responses.d.ts +7 -5
- package/lib/cjs/responses.d.ts.map +1 -1
- package/lib/cjs/responses.js +54 -15
- package/lib/cjs/responses.js.map +1 -1
- package/lib/cjs/route-args/FromSession.d.ts +1 -0
- package/lib/cjs/route-args/FromSession.d.ts.map +1 -0
- package/lib/cjs/route-args/FromSession.js +1 -0
- package/lib/cjs/route-args/FromSession.js.map +1 -0
- package/lib/mjs/interfaces.d.ts +19 -0
- package/lib/mjs/interfaces.d.ts.map +1 -1
- package/lib/mjs/interfaces.js +4 -0
- package/lib/mjs/interfaces.js.map +1 -1
- package/lib/mjs/middlewares/RequestId.d.ts +1 -1
- package/lib/mjs/middlewares/RequestId.d.ts.map +1 -1
- package/lib/mjs/middlewares/RequestId.js +4 -1
- package/lib/mjs/middlewares/RequestId.js.map +1 -1
- package/lib/mjs/response-methods/badRequest.d.ts +4 -8
- package/lib/mjs/response-methods/badRequest.d.ts.map +1 -1
- package/lib/mjs/response-methods/badRequest.js +16 -11
- package/lib/mjs/response-methods/badRequest.js.map +1 -1
- package/lib/mjs/response-methods/conflict.d.ts +5 -3
- package/lib/mjs/response-methods/conflict.d.ts.map +1 -1
- package/lib/mjs/response-methods/conflict.js +8 -4
- package/lib/mjs/response-methods/conflict.js.map +1 -1
- package/lib/mjs/response-methods/created.d.ts +3 -2
- package/lib/mjs/response-methods/created.d.ts.map +1 -1
- package/lib/mjs/response-methods/created.js +6 -2
- package/lib/mjs/response-methods/created.js.map +1 -1
- package/lib/mjs/response-methods/entityTooLarge.d.ts +3 -2
- package/lib/mjs/response-methods/entityTooLarge.d.ts.map +1 -1
- package/lib/mjs/response-methods/entityTooLarge.js +6 -2
- package/lib/mjs/response-methods/entityTooLarge.js.map +1 -1
- package/lib/mjs/response-methods/file.d.ts +7 -4
- package/lib/mjs/response-methods/file.d.ts.map +1 -1
- package/lib/mjs/response-methods/file.js +13 -3
- package/lib/mjs/response-methods/file.js.map +1 -1
- package/lib/mjs/response-methods/forbidden.d.ts +5 -3
- package/lib/mjs/response-methods/forbidden.d.ts.map +1 -1
- package/lib/mjs/response-methods/forbidden.js +8 -4
- package/lib/mjs/response-methods/forbidden.js.map +1 -1
- package/lib/mjs/response-methods/index.d.ts +0 -1
- package/lib/mjs/response-methods/index.d.ts.map +1 -1
- package/lib/mjs/response-methods/index.js +0 -1
- package/lib/mjs/response-methods/index.js.map +1 -1
- package/lib/mjs/response-methods/noContent.d.ts +5 -3
- package/lib/mjs/response-methods/noContent.d.ts.map +1 -1
- package/lib/mjs/response-methods/noContent.js +8 -4
- package/lib/mjs/response-methods/noContent.js.map +1 -1
- package/lib/mjs/response-methods/notAcceptable.d.ts +5 -3
- package/lib/mjs/response-methods/notAcceptable.d.ts.map +1 -1
- package/lib/mjs/response-methods/notAcceptable.js +8 -4
- package/lib/mjs/response-methods/notAcceptable.js.map +1 -1
- package/lib/mjs/response-methods/notAllowed.d.ts +5 -3
- package/lib/mjs/response-methods/notAllowed.d.ts.map +1 -1
- package/lib/mjs/response-methods/notAllowed.js +8 -4
- package/lib/mjs/response-methods/notAllowed.js.map +1 -1
- package/lib/mjs/response-methods/notFound.d.ts +5 -3
- package/lib/mjs/response-methods/notFound.d.ts.map +1 -1
- package/lib/mjs/response-methods/notFound.js +8 -4
- package/lib/mjs/response-methods/notFound.js.map +1 -1
- package/lib/mjs/response-methods/ok.d.ts +3 -2
- package/lib/mjs/response-methods/ok.d.ts.map +1 -1
- package/lib/mjs/response-methods/ok.js +6 -2
- package/lib/mjs/response-methods/ok.js.map +1 -1
- package/lib/mjs/response-methods/serverError.d.ts +5 -3
- package/lib/mjs/response-methods/serverError.d.ts.map +1 -1
- package/lib/mjs/response-methods/serverError.js +8 -4
- package/lib/mjs/response-methods/serverError.js.map +1 -1
- package/lib/mjs/response-methods/template.d.ts +3 -3
- package/lib/mjs/response-methods/template.d.ts.map +1 -1
- package/lib/mjs/response-methods/template.js +6 -4
- package/lib/mjs/response-methods/template.js.map +1 -1
- package/lib/mjs/response-methods/unauthorized.d.ts +5 -3
- package/lib/mjs/response-methods/unauthorized.d.ts.map +1 -1
- package/lib/mjs/response-methods/unauthorized.js +8 -4
- package/lib/mjs/response-methods/unauthorized.js.map +1 -1
- package/lib/mjs/response-methods/validationError.d.ts +5 -3
- package/lib/mjs/response-methods/validationError.d.ts.map +1 -1
- package/lib/mjs/response-methods/validationError.js +8 -4
- package/lib/mjs/response-methods/validationError.js.map +1 -1
- package/lib/mjs/responses.d.ts +7 -5
- package/lib/mjs/responses.d.ts.map +1 -1
- package/lib/mjs/responses.js +51 -14
- package/lib/mjs/responses.js.map +1 -1
- package/lib/mjs/route-args/FromSession.d.ts +2 -0
- package/lib/mjs/route-args/FromSession.d.ts.map +1 -0
- package/lib/mjs/route-args/FromSession.js +2 -0
- package/lib/mjs/route-args/FromSession.js.map +1 -0
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/lib/cjs/response-methods/cookieResponse.d.ts +0 -20
- package/lib/cjs/response-methods/cookieResponse.d.ts.map +0 -1
- package/lib/cjs/response-methods/cookieResponse.js +0 -74
- package/lib/cjs/response-methods/cookieResponse.js.map +0 -1
- package/lib/cjs/response-methods/errorResponse.d.ts +0 -8
- package/lib/cjs/response-methods/errorResponse.d.ts.map +0 -1
- package/lib/cjs/response-methods/errorResponse.js +0 -25
- package/lib/cjs/response-methods/errorResponse.js.map +0 -1
- package/lib/mjs/response-methods/cookieResponse.d.ts +0 -20
- package/lib/mjs/response-methods/cookieResponse.d.ts.map +0 -1
- package/lib/mjs/response-methods/cookieResponse.js +0 -47
- package/lib/mjs/response-methods/cookieResponse.js.map +0 -1
- package/lib/mjs/response-methods/errorResponse.d.ts +0 -8
- package/lib/mjs/response-methods/errorResponse.d.ts.map +0 -1
- package/lib/mjs/response-methods/errorResponse.js +0 -18
- 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.
|
|
3
|
+
"version": "2.0.187",
|
|
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.
|
|
65
|
-
"@spinajs/di": "^2.0.
|
|
66
|
-
"@spinajs/exceptions": "^2.0.
|
|
67
|
-
"@spinajs/fs": "^2.0.
|
|
68
|
-
"@spinajs/log": "^2.0.
|
|
69
|
-
"@spinajs/reflection": "^2.0.
|
|
70
|
-
"@spinajs/templates": "^2.0.
|
|
71
|
-
"@spinajs/validation": "^2.0.
|
|
72
|
-
"@spinajs/templates-pug": "^2.0.
|
|
73
|
-
"@spinajs/util": "^2.0.
|
|
64
|
+
"@spinajs/configuration": "^2.0.187",
|
|
65
|
+
"@spinajs/di": "^2.0.187",
|
|
66
|
+
"@spinajs/exceptions": "^2.0.187",
|
|
67
|
+
"@spinajs/fs": "^2.0.187",
|
|
68
|
+
"@spinajs/log": "^2.0.187",
|
|
69
|
+
"@spinajs/reflection": "^2.0.187",
|
|
70
|
+
"@spinajs/templates": "^2.0.187",
|
|
71
|
+
"@spinajs/validation": "^2.0.187",
|
|
72
|
+
"@spinajs/templates-pug": "^2.0.187",
|
|
73
|
+
"@spinajs/util": "^2.0.187",
|
|
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
|
|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S,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,IA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BAAgB,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"}
|