routup 0.0.1
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/LICENSE +21 -0
- package/README.md +74 -0
- package/dist/constants.d.ts +20 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +31 -0
- package/dist/constants.js.map +1 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +25 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/request/body.d.ts +5 -0
- package/dist/helpers/request/body.d.ts.map +1 -0
- package/dist/helpers/request/body.js +19 -0
- package/dist/helpers/request/body.js.map +1 -0
- package/dist/helpers/request/cache.d.ts +3 -0
- package/dist/helpers/request/cache.d.ts.map +1 -0
- package/dist/helpers/request/cache.js +21 -0
- package/dist/helpers/request/cache.js.map +1 -0
- package/dist/helpers/request/env.d.ts +4 -0
- package/dist/helpers/request/env.d.ts.map +1 -0
- package/dist/helpers/request/env.js +27 -0
- package/dist/helpers/request/env.js.map +1 -0
- package/dist/helpers/request/header-accept-charset.d.ts +7 -0
- package/dist/helpers/request/header-accept-charset.d.ts.map +1 -0
- package/dist/helpers/request/header-accept-charset.js +21 -0
- package/dist/helpers/request/header-accept-charset.js.map +1 -0
- package/dist/helpers/request/header-accept-encoding.d.ts +7 -0
- package/dist/helpers/request/header-accept-encoding.d.ts.map +1 -0
- package/dist/helpers/request/header-accept-encoding.js +21 -0
- package/dist/helpers/request/header-accept-encoding.js.map +1 -0
- package/dist/helpers/request/header-accept-language.d.ts +7 -0
- package/dist/helpers/request/header-accept-language.d.ts.map +1 -0
- package/dist/helpers/request/header-accept-language.js +21 -0
- package/dist/helpers/request/header-accept-language.js.map +1 -0
- package/dist/helpers/request/header-accept.d.ts +7 -0
- package/dist/helpers/request/header-accept.d.ts.map +1 -0
- package/dist/helpers/request/header-accept.js +45 -0
- package/dist/helpers/request/header-accept.js.map +1 -0
- package/dist/helpers/request/header-content-type.d.ts +4 -0
- package/dist/helpers/request/header-content-type.d.ts.map +1 -0
- package/dist/helpers/request/header-content-type.js +28 -0
- package/dist/helpers/request/header-content-type.js.map +1 -0
- package/dist/helpers/request/header.d.ts +5 -0
- package/dist/helpers/request/header.d.ts.map +1 -0
- package/dist/helpers/request/header.js +18 -0
- package/dist/helpers/request/header.js.map +1 -0
- package/dist/helpers/request/index.d.ts +13 -0
- package/dist/helpers/request/index.d.ts.map +1 -0
- package/dist/helpers/request/index.js +35 -0
- package/dist/helpers/request/index.js.map +1 -0
- package/dist/helpers/request/mount-path.d.ts +6 -0
- package/dist/helpers/request/mount-path.d.ts.map +1 -0
- package/dist/helpers/request/mount-path.js +22 -0
- package/dist/helpers/request/mount-path.js.map +1 -0
- package/dist/helpers/request/negotiator.d.ts +5 -0
- package/dist/helpers/request/negotiator.d.ts.map +1 -0
- package/dist/helpers/request/negotiator.js +22 -0
- package/dist/helpers/request/negotiator.js.map +1 -0
- package/dist/helpers/request/params.d.ts +5 -0
- package/dist/helpers/request/params.d.ts.map +1 -0
- package/dist/helpers/request/params.js +25 -0
- package/dist/helpers/request/params.js.map +1 -0
- package/dist/helpers/request/path.d.ts +4 -0
- package/dist/helpers/request/path.d.ts.map +1 -0
- package/dist/helpers/request/path.js +21 -0
- package/dist/helpers/request/path.js.map +1 -0
- package/dist/helpers/response/body.d.ts +7 -0
- package/dist/helpers/response/body.d.ts.map +1 -0
- package/dist/helpers/response/body.js +48 -0
- package/dist/helpers/response/body.js.map +1 -0
- package/dist/helpers/response/cache.d.ts +8 -0
- package/dist/helpers/response/cache.d.ts.map +1 -0
- package/dist/helpers/response/cache.js +25 -0
- package/dist/helpers/response/cache.js.map +1 -0
- package/dist/helpers/response/header-attachment.d.ts +4 -0
- package/dist/helpers/response/header-attachment.d.ts.map +1 -0
- package/dist/helpers/response/header-attachment.js +29 -0
- package/dist/helpers/response/header-attachment.js.map +1 -0
- package/dist/helpers/response/header-content-type.d.ts +4 -0
- package/dist/helpers/response/header-content-type.d.ts.map +1 -0
- package/dist/helpers/response/header-content-type.js +25 -0
- package/dist/helpers/response/header-content-type.js.map +1 -0
- package/dist/helpers/response/header.d.ts +4 -0
- package/dist/helpers/response/header.d.ts.map +1 -0
- package/dist/helpers/response/header.js +39 -0
- package/dist/helpers/response/header.js.map +1 -0
- package/dist/helpers/response/index.d.ts +10 -0
- package/dist/helpers/response/index.d.ts.map +1 -0
- package/dist/helpers/response/index.js +32 -0
- package/dist/helpers/response/index.js.map +1 -0
- package/dist/helpers/response/send-file.d.ts +5 -0
- package/dist/helpers/response/send-file.d.ts.map +1 -0
- package/dist/helpers/response/send-file.js +27 -0
- package/dist/helpers/response/send-file.js.map +1 -0
- package/dist/helpers/response/send-format.d.ts +5 -0
- package/dist/helpers/response/send-format.d.ts.map +1 -0
- package/dist/helpers/response/send-format.js +13 -0
- package/dist/helpers/response/send-format.js.map +1 -0
- package/dist/helpers/response/send-redirect.d.ts +3 -0
- package/dist/helpers/response/send-redirect.d.ts.map +1 -0
- package/dist/helpers/response/send-redirect.js +19 -0
- package/dist/helpers/response/send-redirect.js.map +1 -0
- package/dist/helpers/response/send-stream.d.ts +7 -0
- package/dist/helpers/response/send-stream.d.ts.map +1 -0
- package/dist/helpers/response/send-stream.js +33 -0
- package/dist/helpers/response/send-stream.js.map +1 -0
- package/dist/helpers/response/send.d.ts +3 -0
- package/dist/helpers/response/send.d.ts.map +1 -0
- package/dist/helpers/response/send.js +100 -0
- package/dist/helpers/response/send.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/layer/index.d.ts +3 -0
- package/dist/layer/index.d.ts.map +1 -0
- package/dist/layer/index.js +25 -0
- package/dist/layer/index.js.map +1 -0
- package/dist/layer/module.d.ts +15 -0
- package/dist/layer/module.d.ts.map +1 -0
- package/dist/layer/module.js +72 -0
- package/dist/layer/module.js.map +1 -0
- package/dist/layer/utils.d.ts +3 -0
- package/dist/layer/utils.d.ts.map +1 -0
- package/dist/layer/utils.js +15 -0
- package/dist/layer/utils.js.map +1 -0
- package/dist/path/index.d.ts +3 -0
- package/dist/path/index.d.ts.map +1 -0
- package/dist/path/index.js +25 -0
- package/dist/path/index.js.map +1 -0
- package/dist/path/matcher.d.ts +13 -0
- package/dist/path/matcher.d.ts.map +1 -0
- package/dist/path/matcher.js +73 -0
- package/dist/path/matcher.js.map +1 -0
- package/dist/path/type.d.ts +5 -0
- package/dist/path/type.d.ts.map +1 -0
- package/dist/path/type.js +9 -0
- package/dist/path/type.js.map +1 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.d.ts.map +1 -0
- package/dist/route/index.js +25 -0
- package/dist/route/index.js.map +1 -0
- package/dist/route/module.d.ts +21 -0
- package/dist/route/module.d.ts.map +1 -0
- package/dist/route/module.js +87 -0
- package/dist/route/module.js.map +1 -0
- package/dist/route/utils.d.ts +3 -0
- package/dist/route/utils.d.ts.map +1 -0
- package/dist/route/utils.js +15 -0
- package/dist/route/utils.js.map +1 -0
- package/dist/router/index.d.ts +3 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +25 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/module.d.ts +40 -0
- package/dist/router/module.d.ts.map +1 -0
- package/dist/router/module.js +229 -0
- package/dist/router/module.js.map +1 -0
- package/dist/router/type.d.ts +18 -0
- package/dist/router/type.d.ts.map +1 -0
- package/dist/router/type.js +9 -0
- package/dist/router/type.js.map +1 -0
- package/dist/type.d.ts +25 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +9 -0
- package/dist/type.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +28 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/is-instance.d.ts +2 -0
- package/dist/utils/is-instance.d.ts.map +1 -0
- package/dist/utils/is-instance.js +16 -0
- package/dist/utils/is-instance.js.map +1 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +21 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/path.d.ts +3 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +14 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/response.d.ts +3 -0
- package/dist/utils/response.d.ts.map +1 -0
- package/dist/utils/response.js +31 -0
- package/dist/utils/response.js.map +1 -0
- package/dist/utils/url.d.ts +8 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/url.js +58 -0
- package/dist/utils/url.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/request/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,+CAA6B;AAC7B,yCAAuB;AACvB,wCAAsB;AACtB,2CAAyB;AACzB,kDAAgC;AAChC,0DAAwC;AACxC,2DAAyC;AACzC,2DAAyC;AACzC,wDAAsC;AACtC,+CAA6B;AAC7B,2CAAyB;AACzB,yCAAuB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
import { Path } from '../../type';
|
|
4
|
+
export declare function useRequestMountPath(req: IncomingMessage): Path;
|
|
5
|
+
export declare function setRequestMountPath(req: IncomingMessage, basePath: Path): void;
|
|
6
|
+
//# sourceMappingURL=mount-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-path.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/mount-path.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlC,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAI,IAAI,CAM/D;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,IAAI,QAEvE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.setRequestMountPath = exports.useRequestMountPath = void 0;
|
|
10
|
+
const ReqMountPathSymbol = Symbol.for('ReqMountPath');
|
|
11
|
+
function useRequestMountPath(req) {
|
|
12
|
+
if (ReqMountPathSymbol in req) {
|
|
13
|
+
return req[ReqMountPathSymbol];
|
|
14
|
+
}
|
|
15
|
+
return '/';
|
|
16
|
+
}
|
|
17
|
+
exports.useRequestMountPath = useRequestMountPath;
|
|
18
|
+
function setRequestMountPath(req, basePath) {
|
|
19
|
+
req[ReqMountPathSymbol] = basePath;
|
|
20
|
+
}
|
|
21
|
+
exports.setRequestMountPath = setRequestMountPath;
|
|
22
|
+
//# sourceMappingURL=mount-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-path.js","sourceRoot":"","sources":["../../../src/helpers/request/mount-path.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAKH,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AAEtD,SAAgB,mBAAmB,CAAC,GAAoB;IACpD,IAAI,kBAAkB,IAAI,GAAG,EAAE;QAC3B,OAAQ,GAAW,CAAC,kBAAkB,CAAC,CAAC;KAC3C;IAED,OAAO,GAAG,CAAC;AACf,CAAC;AAND,kDAMC;AAED,SAAgB,mBAAmB,CAAC,GAAoB,EAAE,QAAc;IACnE,GAAW,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAAC;AAChD,CAAC;AAFD,kDAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negotiator.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/negotiator.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,UAAU,MAAM,YAAY,CAAC;AAIpC,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,GAAI,UAAU,CAMtE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useRequestNegotiator = void 0;
|
|
13
|
+
const negotiator_1 = __importDefault(require("negotiator"));
|
|
14
|
+
const NegotiatorSymbol = Symbol.for('ReqNegotiator');
|
|
15
|
+
function useRequestNegotiator(req) {
|
|
16
|
+
if (NegotiatorSymbol in req) {
|
|
17
|
+
return req[NegotiatorSymbol];
|
|
18
|
+
}
|
|
19
|
+
return new negotiator_1.default(req);
|
|
20
|
+
}
|
|
21
|
+
exports.useRequestNegotiator = useRequestNegotiator;
|
|
22
|
+
//# sourceMappingURL=negotiator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negotiator.js","sourceRoot":"","sources":["../../../src/helpers/request/negotiator.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAGH,4DAAoC;AAEpC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAErD,SAAgB,oBAAoB,CAAC,GAAoB;IACrD,IAAI,gBAAgB,IAAI,GAAG,EAAE;QACzB,OAAQ,GAAW,CAAC,gBAAgB,CAAC,CAAC;KACzC;IAED,OAAO,IAAI,oBAAU,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC;AAND,oDAMC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
export declare function useRequestParams(req: IncomingMessage): Record<string, any>;
|
|
4
|
+
export declare function setRequestParams(req: IncomingMessage, data: Record<string, any>): void;
|
|
5
|
+
//# sourceMappingURL=params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/params.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAIvC,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,GAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAU3E;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAE/E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.setRequestParams = exports.useRequestParams = void 0;
|
|
10
|
+
const ParamsSymbol = Symbol.for('ReqParams');
|
|
11
|
+
function useRequestParams(req) {
|
|
12
|
+
if ('params' in req) {
|
|
13
|
+
return req.params;
|
|
14
|
+
}
|
|
15
|
+
if (ParamsSymbol in req) {
|
|
16
|
+
return req[ParamsSymbol];
|
|
17
|
+
}
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
exports.useRequestParams = useRequestParams;
|
|
21
|
+
function setRequestParams(req, data) {
|
|
22
|
+
req[ParamsSymbol] = data;
|
|
23
|
+
}
|
|
24
|
+
exports.setRequestParams = setRequestParams;
|
|
25
|
+
//# sourceMappingURL=params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../../src/helpers/request/params.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAE7C,SAAgB,gBAAgB,CAAC,GAAoB;IACjD,IAAI,QAAQ,IAAI,GAAG,EAAE;QACjB,OAAQ,GAAW,CAAC,MAAM,CAAC;KAC9B;IAED,IAAI,YAAY,IAAI,GAAG,EAAE;QACrB,OAAQ,GAAW,CAAC,YAAY,CAAC,CAAC;KACrC;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAVD,4CAUC;AAED,SAAgB,gBAAgB,CAAC,GAAoB,EAAE,IAAyB;IAC3E,GAAW,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;AACtC,CAAC;AAFD,4CAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/path.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAI,MAAM,CAY5D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.useRequestPath = void 0;
|
|
10
|
+
function useRequestPath(req) {
|
|
11
|
+
if ('path' in req) {
|
|
12
|
+
return req.path;
|
|
13
|
+
}
|
|
14
|
+
if (typeof req.url === 'undefined') {
|
|
15
|
+
return '/';
|
|
16
|
+
}
|
|
17
|
+
const parsed = new URL(req.url, 'http://localhost/');
|
|
18
|
+
return parsed.pathname;
|
|
19
|
+
}
|
|
20
|
+
exports.useRequestPath = useRequestPath;
|
|
21
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/helpers/request/path.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,SAAgB,cAAc,CAAC,GAAoB;IAC/C,IAAI,MAAM,IAAI,GAAG,EAAE;QACf,OAAQ,GAAW,CAAC,IAAI,CAAC;KAC5B;IAED,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,WAAW,EAAE;QAChC,OAAO,GAAG,CAAC;KACd;IAED,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;IAErD,OAAO,MAAM,CAAC,QAAQ,CAAC;AAC3B,CAAC;AAZD,wCAYC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { ServerResponse } from 'http';
|
|
4
|
+
export declare function useResponseBody(res: ServerResponse): Buffer | undefined;
|
|
5
|
+
export declare function setResponseBody(res: ServerResponse, body: Buffer): void;
|
|
6
|
+
export declare function useResponseBodyFormatted(res: ServerResponse): unknown;
|
|
7
|
+
//# sourceMappingURL=body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/body.ts"],"names":[],"mappings":";;AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAKtC,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAI,MAAM,GAAG,SAAS,CAMxE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,QAEhE;AAGD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,cAAc,GAAI,OAAO,CAyBtE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.useResponseBodyFormatted = exports.setResponseBody = exports.useResponseBody = void 0;
|
|
10
|
+
const constants_1 = require("../../constants");
|
|
11
|
+
const BodySymbol = Symbol.for('ResBody');
|
|
12
|
+
function useResponseBody(res) {
|
|
13
|
+
if (BodySymbol in res) {
|
|
14
|
+
return res[BodySymbol];
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
exports.useResponseBody = useResponseBody;
|
|
19
|
+
function setResponseBody(res, body) {
|
|
20
|
+
res[BodySymbol] = body;
|
|
21
|
+
}
|
|
22
|
+
exports.setResponseBody = setResponseBody;
|
|
23
|
+
/* istanbul ignore next */
|
|
24
|
+
function useResponseBodyFormatted(res) {
|
|
25
|
+
const body = useResponseBody(res);
|
|
26
|
+
if (typeof body === 'undefined') {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
let contentType = res.getHeader(constants_1.HeaderName.CONTENT_TYPE);
|
|
30
|
+
if (!contentType) {
|
|
31
|
+
return contentType;
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(contentType)) {
|
|
34
|
+
contentType = contentType.shift();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
contentType = `${contentType}`.split('; ').shift();
|
|
38
|
+
}
|
|
39
|
+
switch (contentType) {
|
|
40
|
+
case 'application/json':
|
|
41
|
+
return JSON.parse(body.toString('utf-8'));
|
|
42
|
+
case 'text/html':
|
|
43
|
+
return body.toString('utf-8');
|
|
44
|
+
}
|
|
45
|
+
return body;
|
|
46
|
+
}
|
|
47
|
+
exports.useResponseBodyFormatted = useResponseBodyFormatted;
|
|
48
|
+
//# sourceMappingURL=body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.js","sourceRoot":"","sources":["../../../src/helpers/response/body.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,+CAA6C;AAE7C,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAEzC,SAAgB,eAAe,CAAC,GAAmB;IAC/C,IAAI,UAAU,IAAI,GAAG,EAAE;QACnB,OAAQ,GAAW,CAAC,UAAU,CAAC,CAAC;KACnC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAND,0CAMC;AAED,SAAgB,eAAe,CAAC,GAAmB,EAAE,IAAY;IAC5D,GAAW,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;AACpC,CAAC;AAFD,0CAEC;AAED,0BAA0B;AAC1B,SAAgB,wBAAwB,CAAC,GAAmB;IACxD,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;QAC7B,OAAO,SAAS,CAAC;KACpB;IAED,IAAI,WAAW,GAAG,GAAG,CAAC,SAAS,CAAC,sBAAU,CAAC,YAAY,CAAC,CAAC;IACzD,IAAI,CAAC,WAAW,EAAE;QACd,OAAO,WAAW,CAAC;KACtB;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QAC5B,WAAW,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC;KACrC;SAAM;QACH,WAAW,GAAG,GAAG,WAAW,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;KACtD;IAED,QAAQ,WAAW,EAAE;QACjB,KAAK,kBAAkB;YACnB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9C,KAAK,WAAW;YACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;KACrC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAzBD,4DAyBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Response } from '../../type';
|
|
2
|
+
export declare type ResponseCacheHeadersOptions = {
|
|
3
|
+
maxAge?: number;
|
|
4
|
+
modifiedTime?: string | Date;
|
|
5
|
+
cacheControls?: string[];
|
|
6
|
+
};
|
|
7
|
+
export declare function setResponseCacheHeaders(res: Response, options?: ResponseCacheHeadersOptions): void;
|
|
8
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/cache.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,oBAAY,2BAA2B,GAAG;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,2BAA2B,QAkB3F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.setResponseCacheHeaders = void 0;
|
|
10
|
+
function setResponseCacheHeaders(res, options) {
|
|
11
|
+
options = options || {};
|
|
12
|
+
const cacheControls = ['public'].concat(options.cacheControls || []);
|
|
13
|
+
if (options.maxAge !== undefined) {
|
|
14
|
+
cacheControls.push(`max-age=${+options.maxAge}`, `s-maxage=${+options.maxAge}`);
|
|
15
|
+
}
|
|
16
|
+
if (options.modifiedTime) {
|
|
17
|
+
const modifiedTime = typeof options.modifiedTime === 'string' ?
|
|
18
|
+
new Date(options.modifiedTime) :
|
|
19
|
+
options.modifiedTime;
|
|
20
|
+
res.setHeader('last-modified', modifiedTime.toUTCString());
|
|
21
|
+
}
|
|
22
|
+
res.setHeader('cache-control', cacheControls.join(', '));
|
|
23
|
+
}
|
|
24
|
+
exports.setResponseCacheHeaders = setResponseCacheHeaders;
|
|
25
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/helpers/response/cache.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAUH,SAAgB,uBAAuB,CAAC,GAAa,EAAE,OAAqC;IACxF,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;IAExB,MAAM,aAAa,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IAErE,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;QAC9B,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;KACnF;IAED,IAAI,OAAO,CAAC,YAAY,EAAE;QACtB,MAAM,YAAY,GAAG,OAAO,OAAO,CAAC,YAAY,KAAK,QAAQ,CAAC,CAAC;YAC3D,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;YAChC,OAAO,CAAC,YAAY,CAAC;QAEzB,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;KAC9D;IAED,GAAG,CAAC,SAAS,CAAC,eAAe,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7D,CAAC;AAlBD,0DAkBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-attachment.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/header-attachment.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAKtC,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,MAAM,QAejF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.setResponseHeaderAttachment = void 0;
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const constants_1 = require("../../constants");
|
|
15
|
+
const utils_1 = require("../../utils");
|
|
16
|
+
function setResponseHeaderAttachment(res, filename) {
|
|
17
|
+
if (typeof filename === 'string') {
|
|
18
|
+
const ext = path_1.default.extname(filename);
|
|
19
|
+
if (ext) {
|
|
20
|
+
const type = (0, utils_1.getMimeType)(ext.substring(1));
|
|
21
|
+
if (type) {
|
|
22
|
+
res.setHeader(constants_1.HeaderName.CONTENT_TYPE, type);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
res.setHeader(constants_1.HeaderName.CONTENT_DISPOSITION, `attachment${filename ? `; filename="${filename}"` : ''}`);
|
|
27
|
+
}
|
|
28
|
+
exports.setResponseHeaderAttachment = setResponseHeaderAttachment;
|
|
29
|
+
//# sourceMappingURL=header-attachment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-attachment.js","sourceRoot":"","sources":["../../../src/helpers/response/header-attachment.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAGH,gDAAwB;AACxB,+CAA6C;AAC7C,uCAA0C;AAE1C,SAAgB,2BAA2B,CAAC,GAAmB,EAAE,QAAiB;IAC9E,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAC9B,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,GAAG,EAAE;YACL,MAAM,IAAI,GAAG,IAAA,mBAAW,EAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3C,IAAI,IAAI,EAAE;gBACN,GAAG,CAAC,SAAS,CAAC,sBAAU,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;aAChD;SACJ;KACJ;IAED,GAAG,CAAC,SAAS,CACT,sBAAU,CAAC,mBAAmB,EAC9B,aAAa,QAAQ,CAAC,CAAC,CAAC,eAAe,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5D,CAAC;AACN,CAAC;AAfD,kEAeC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-content-type.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/header-content-type.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAItC,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,QAYrG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.setResponseHeaderContentType = void 0;
|
|
10
|
+
const constants_1 = require("../../constants");
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
function setResponseHeaderContentType(res, input, ifNotExists) {
|
|
13
|
+
if (ifNotExists) {
|
|
14
|
+
const header = res.getHeader(constants_1.HeaderName.CONTENT_TYPE);
|
|
15
|
+
if (header) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const contentType = (0, utils_1.getMimeType)(input);
|
|
20
|
+
if (contentType) {
|
|
21
|
+
res.setHeader(constants_1.HeaderName.CONTENT_TYPE, contentType);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.setResponseHeaderContentType = setResponseHeaderContentType;
|
|
25
|
+
//# sourceMappingURL=header-content-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-content-type.js","sourceRoot":"","sources":["../../../src/helpers/response/header-content-type.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,+CAA6C;AAC7C,uCAA0C;AAE1C,SAAgB,4BAA4B,CAAC,GAAmB,EAAE,KAAa,EAAE,WAAqB;IAClG,IAAI,WAAW,EAAE;QACb,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,sBAAU,CAAC,YAAY,CAAC,CAAC;QACtD,IAAI,MAAM,EAAE;YACR,OAAO;SACV;KACJ;IAED,MAAM,WAAW,GAAG,IAAA,mBAAW,EAAC,KAAK,CAAC,CAAC;IACvC,IAAI,WAAW,EAAE;QACb,GAAG,CAAC,SAAS,CAAC,sBAAU,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;KACvD;AACL,CAAC;AAZD,oEAYC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/header.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE1D,wBAAgB,6BAA6B,CACzC,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,kBAAkB,QAiC5B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.appendResponseHeaderDirective = void 0;
|
|
10
|
+
function appendResponseHeaderDirective(res, name, value) {
|
|
11
|
+
let header = res.getHeader(name);
|
|
12
|
+
if (!header) {
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
res.setHeader(name, value.join('; '));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
res.setHeader(name, value);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (!Array.isArray(header)) {
|
|
21
|
+
if (typeof header === 'string') {
|
|
22
|
+
// split header by directive(s)
|
|
23
|
+
header = header.split('; ');
|
|
24
|
+
}
|
|
25
|
+
if (typeof header === 'number') {
|
|
26
|
+
header = [header.toString()];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
header.push(...value);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
header.push(`${value}`);
|
|
34
|
+
}
|
|
35
|
+
// todo: check for unique values
|
|
36
|
+
res.setHeader(name, header.join('; '));
|
|
37
|
+
}
|
|
38
|
+
exports.appendResponseHeaderDirective = appendResponseHeaderDirective;
|
|
39
|
+
//# sourceMappingURL=header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.js","sourceRoot":"","sources":["../../../src/helpers/response/header.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,SAAgB,6BAA6B,CACzC,GAAmB,EACnB,IAAY,EACZ,KAAyB;IAEzB,IAAI,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,MAAM,EAAE;QACT,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YACtB,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACtC,OAAO;SACV;QAED,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3B,OAAO;KACV;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACxB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC5B,+BAA+B;YAC/B,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAC/B;QAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC5B,MAAM,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;SAChC;KACJ;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACtB,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;KACzB;SAAM;QACH,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;KAC3B;IAED,gCAAgC;IAEhC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3C,CAAC;AApCD,sEAoCC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './body';
|
|
2
|
+
export * from './cache';
|
|
3
|
+
export * from './header';
|
|
4
|
+
export * from './header-attachment';
|
|
5
|
+
export * from './header-content-type';
|
|
6
|
+
export * from './send';
|
|
7
|
+
export * from './send-file';
|
|
8
|
+
export * from './send-format';
|
|
9
|
+
export * from './send-stream';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/index.ts"],"names":[],"mappings":"AAOA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022-2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./body"), exports);
|
|
24
|
+
__exportStar(require("./cache"), exports);
|
|
25
|
+
__exportStar(require("./header"), exports);
|
|
26
|
+
__exportStar(require("./header-attachment"), exports);
|
|
27
|
+
__exportStar(require("./header-content-type"), exports);
|
|
28
|
+
__exportStar(require("./send"), exports);
|
|
29
|
+
__exportStar(require("./send-file"), exports);
|
|
30
|
+
__exportStar(require("./send-format"), exports);
|
|
31
|
+
__exportStar(require("./send-stream"), exports);
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/response/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,yCAAuB;AACvB,0CAAwB;AACxB,2CAAyB;AACzB,sDAAoC;AACpC,wDAAsC;AACtC,yCAAuB;AACvB,8CAA4B;AAC5B,gDAA8B;AAC9B,gDAA8B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-file.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/send-file.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAGtC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIlC,wBAAgB,QAAQ,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,IAAI,QASxE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.sendFile = void 0;
|
|
13
|
+
const fs_1 = require("fs");
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const constants_1 = require("../../constants");
|
|
16
|
+
const header_attachment_1 = require("./header-attachment");
|
|
17
|
+
const send_stream_1 = require("./send-stream");
|
|
18
|
+
function sendFile(res, filePath, fn) {
|
|
19
|
+
const dispositionHeader = res.getHeader(constants_1.HeaderName.CONTENT_DISPOSITION);
|
|
20
|
+
if (!dispositionHeader) {
|
|
21
|
+
(0, header_attachment_1.setResponseHeaderAttachment)(res, path_1.default.basename(filePath));
|
|
22
|
+
}
|
|
23
|
+
const stream = (0, fs_1.createReadStream)(filePath);
|
|
24
|
+
(0, send_stream_1.sendStream)(res, stream, fn);
|
|
25
|
+
}
|
|
26
|
+
exports.sendFile = sendFile;
|
|
27
|
+
//# sourceMappingURL=send-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-file.js","sourceRoot":"","sources":["../../../src/helpers/response/send-file.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,2BAAsC;AAEtC,gDAAwB;AACxB,+CAA6C;AAE7C,2DAAkE;AAClE,+CAA2C;AAE3C,SAAgB,QAAQ,CAAC,GAAmB,EAAE,QAAgB,EAAE,EAAS;IACrE,MAAM,iBAAiB,GAAG,GAAG,CAAC,SAAS,CAAC,sBAAU,CAAC,mBAAmB,CAAC,CAAC;IACxE,IAAI,CAAC,iBAAiB,EAAE;QACpB,IAAA,+CAA2B,EAAC,GAAG,EAAE,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;KAC7D;IAED,MAAM,MAAM,GAAG,IAAA,qBAAgB,EAAC,QAAQ,CAAC,CAAC;IAE1C,IAAA,wBAAU,EAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AATD,4BASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-format.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/send-format.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,wBAAgB,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,QAErE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.sendFormat = void 0;
|
|
10
|
+
function sendFormat(res, format) {
|
|
11
|
+
}
|
|
12
|
+
exports.sendFormat = sendFormat;
|
|
13
|
+
//# sourceMappingURL=send-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-format.js","sourceRoot":"","sources":["../../../src/helpers/response/send-format.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAKH,SAAgB,UAAU,CAAC,GAAmB,EAAE,MAAsB;AAEtE,CAAC;AAFD,gCAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-redirect.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/send-redirect.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,SAAM,QAQ7E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.sendRedirect = void 0;
|
|
10
|
+
const send_1 = require("./send");
|
|
11
|
+
function sendRedirect(res, location, statusCode = 302) {
|
|
12
|
+
res.statusCode = statusCode;
|
|
13
|
+
res.setHeader('location', location);
|
|
14
|
+
const encodedLoc = location.replace(/"/g, '%22');
|
|
15
|
+
const html = `<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=${encodedLoc}"></head></html>`;
|
|
16
|
+
return (0, send_1.send)(res, html);
|
|
17
|
+
}
|
|
18
|
+
exports.sendRedirect = sendRedirect;
|
|
19
|
+
//# sourceMappingURL=send-redirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-redirect.js","sourceRoot":"","sources":["../../../src/helpers/response/send-redirect.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,iCAA8B;AAE9B,SAAgB,YAAY,CAAC,GAAa,EAAE,QAAgB,EAAE,UAAU,GAAG,GAAG;IAC1E,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;IAC5B,GAAG,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAEpC,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,yEAAyE,UAAU,kBAAkB,CAAC;IAEnH,OAAO,IAAA,WAAI,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAC3B,CAAC;AARD,oCAQC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { ServerResponse } from 'http';
|
|
4
|
+
import { Readable } from 'stream';
|
|
5
|
+
import { Next } from '../../type';
|
|
6
|
+
export declare function sendStream(res: ServerResponse, stream: Readable, fn?: Next): void;
|
|
7
|
+
//# sourceMappingURL=send-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-stream.d.ts","sourceRoot":"","sources":["../../../src/helpers/response/send-stream.ts"],"names":[],"mappings":";;AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,wBAAgB,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,EAAE,IAAI,QAqB1E"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022.
|
|
4
|
+
* Author Peter Placzek (tada5hi)
|
|
5
|
+
* For the full copyright and license information,
|
|
6
|
+
* view the LICENSE file that was distributed with this source code.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.sendStream = void 0;
|
|
10
|
+
function sendStream(res, stream, fn) {
|
|
11
|
+
stream.on('open', () => {
|
|
12
|
+
stream.pipe(res);
|
|
13
|
+
});
|
|
14
|
+
stream.on('error', (err) => {
|
|
15
|
+
if (typeof fn === 'function') {
|
|
16
|
+
fn(err);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
res.statusCode = 500;
|
|
20
|
+
res.end();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
stream.on('close', () => {
|
|
24
|
+
if (typeof fn === 'function') {
|
|
25
|
+
fn();
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
res.end();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.sendStream = sendStream;
|
|
33
|
+
//# sourceMappingURL=send-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-stream.js","sourceRoot":"","sources":["../../../src/helpers/response/send-stream.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAMH,SAAgB,UAAU,CAAC,GAAmB,EAAE,MAAgB,EAAE,EAAS;IACvE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACnB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;QACvB,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAC1B,EAAE,CAAC,GAAG,CAAC,CAAC;SACX;aAAM;YACH,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;YACrB,GAAG,CAAC,GAAG,EAAE,CAAC;SACb;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACpB,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAC1B,EAAE,EAAE,CAAC;SACR;aAAM;YACH,GAAG,CAAC,GAAG,EAAE,CAAC;SACb;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AArBD,gCAqBC"}
|