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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2022 Peter Placzek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# routup 🛣
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/routup)
|
|
4
|
+
[](https://github.com/Tada5hi/routup/actions/workflows/main.yml)
|
|
5
|
+
[](https://codecov.io/gh/tada5hi/routup)
|
|
6
|
+
[](https://snyk.io/test/github/Tada5hi/routup)
|
|
7
|
+
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
+
|
|
9
|
+
Routup is a minimalistic & extendable http interface based routing framework.
|
|
10
|
+
It uses node's vanilla request and response interfaces, which are injected into route- & middleware-handlers as function argument.
|
|
11
|
+
Helpers provide additional functionalities to transform and interact with the request and manipulate the response upstream.
|
|
12
|
+
|
|
13
|
+
**Table of Contents**
|
|
14
|
+
|
|
15
|
+
- [Installation](#installation)
|
|
16
|
+
- [Features](#features)
|
|
17
|
+
- [Documentation](#documentation)
|
|
18
|
+
- [Usage](#usage)
|
|
19
|
+
- [Plugins](#plugins)
|
|
20
|
+
- [License](#license)
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install routup --save
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
- 🚀 high performance routing
|
|
31
|
+
- 🧰 response & request helpers/utilities
|
|
32
|
+
- 💼 extendable & compact
|
|
33
|
+
- 🛫 named route parameters
|
|
34
|
+
- 📁 nestable routers
|
|
35
|
+
- 😌 define one or many (error-) middlewares
|
|
36
|
+
- ✨ promise support for route- & middleware-handlers
|
|
37
|
+
- 👕 TypeScript fully supported
|
|
38
|
+
- 🤏 Minimalistic to fit into any solution with minimum overhead
|
|
39
|
+
- & much more
|
|
40
|
+
|
|
41
|
+
## Documentation
|
|
42
|
+
|
|
43
|
+
To read the docs, visit [https://routup.tada5hi.net](https://routup.tada5hi.net)
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { Router, send } from 'routup';
|
|
49
|
+
|
|
50
|
+
const router = new Router();
|
|
51
|
+
|
|
52
|
+
router.get('/', (req, res) => {
|
|
53
|
+
send(res, 'Hello World');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
router.listen(3000);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Plugins
|
|
60
|
+
|
|
61
|
+
According to the fact that routup is a minimalistic framework, it depends on plugins to cover some
|
|
62
|
+
typically http framework functions, which are not integrated in the main package.
|
|
63
|
+
|
|
64
|
+
| Name | Description |
|
|
65
|
+
|-----------------------------------------------------------------------------|------------------------------------------------|
|
|
66
|
+
| [cookie](https://www.npmjs.com/package/@routup/tree/master/packages/cookie) | Read and use cookies set in the request header |
|
|
67
|
+
| [query](https://www.npmjs.com/package/@routup/tree/master/packages/query) | Parse and use url query string |
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
Made with 💚
|
|
73
|
+
|
|
74
|
+
Published under [MIT License](./LICENSE).
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare enum Method {
|
|
2
|
+
GET = "get",
|
|
3
|
+
POST = "post",
|
|
4
|
+
PUT = "put",
|
|
5
|
+
PATCH = "patch",
|
|
6
|
+
DELETE = "delete"
|
|
7
|
+
}
|
|
8
|
+
export declare enum HeaderName {
|
|
9
|
+
METHOD = "method",
|
|
10
|
+
URL = "url",
|
|
11
|
+
STATUS_CODE = "staus-code",
|
|
12
|
+
STATUS_MESSAGE = "status-message",
|
|
13
|
+
ACCEPT = "accept",
|
|
14
|
+
CONTENT_DISPOSITION = "content-disposition",
|
|
15
|
+
CONTENT_ENCODING = "content-encoding",
|
|
16
|
+
CONTENT_LENGTH = "content-length",
|
|
17
|
+
CONTENT_TYPE = "content-type",
|
|
18
|
+
COOKIE = "cookie"
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,MAAM;IACd,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,KAAK,UAAU;IACf,MAAM,WAAW;CACpB;AAED,oBAAY,UAAU;IAClB,MAAM,WAAW;IACjB,GAAG,QAAQ;IACX,WAAW,eAAe;IAC1B,cAAc,mBAAmB;IAEjC,MAAM,WAAW;IACjB,mBAAmB,wBAAwB;IAC3C,gBAAgB,qBAAqB;IACrC,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;IAC7B,MAAM,WAAW;CACpB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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.HeaderName = exports.Method = void 0;
|
|
10
|
+
var Method;
|
|
11
|
+
(function (Method) {
|
|
12
|
+
Method["GET"] = "get";
|
|
13
|
+
Method["POST"] = "post";
|
|
14
|
+
Method["PUT"] = "put";
|
|
15
|
+
Method["PATCH"] = "patch";
|
|
16
|
+
Method["DELETE"] = "delete";
|
|
17
|
+
})(Method = exports.Method || (exports.Method = {}));
|
|
18
|
+
var HeaderName;
|
|
19
|
+
(function (HeaderName) {
|
|
20
|
+
HeaderName["METHOD"] = "method";
|
|
21
|
+
HeaderName["URL"] = "url";
|
|
22
|
+
HeaderName["STATUS_CODE"] = "staus-code";
|
|
23
|
+
HeaderName["STATUS_MESSAGE"] = "status-message";
|
|
24
|
+
HeaderName["ACCEPT"] = "accept";
|
|
25
|
+
HeaderName["CONTENT_DISPOSITION"] = "content-disposition";
|
|
26
|
+
HeaderName["CONTENT_ENCODING"] = "content-encoding";
|
|
27
|
+
HeaderName["CONTENT_LENGTH"] = "content-length";
|
|
28
|
+
HeaderName["CONTENT_TYPE"] = "content-type";
|
|
29
|
+
HeaderName["COOKIE"] = "cookie";
|
|
30
|
+
})(HeaderName = exports.HeaderName || (exports.HeaderName = {}));
|
|
31
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,IAAY,MAMX;AAND,WAAY,MAAM;IACd,qBAAW,CAAA;IACX,uBAAa,CAAA;IACb,qBAAW,CAAA;IACX,yBAAe,CAAA;IACf,2BAAiB,CAAA;AACrB,CAAC,EANW,MAAM,GAAN,cAAM,KAAN,cAAM,QAMjB;AAED,IAAY,UAYX;AAZD,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,yBAAW,CAAA;IACX,wCAA0B,CAAA;IAC1B,+CAAiC,CAAA;IAEjC,+BAAiB,CAAA;IACjB,yDAA2C,CAAA;IAC3C,mDAAqC,CAAA;IACrC,+CAAiC,CAAA;IACjC,2CAA6B,CAAA;IAC7B,+BAAiB,CAAA;AACrB,CAAC,EAZW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAYrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAOA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
|
|
@@ -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
|
+
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("./request"), exports);
|
|
24
|
+
__exportStar(require("./response"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,4CAA0B;AAC1B,6CAA2B"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
export declare function useRequestBody(req: IncomingMessage): unknown | undefined;
|
|
4
|
+
export declare function setRequestBody(req: IncomingMessage, body: unknown): void;
|
|
5
|
+
//# sourceMappingURL=body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/body.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAIvC,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,GAAI,OAAO,GAAG,SAAS,CAUzE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,QAEjE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setRequestBody = exports.useRequestBody = void 0;
|
|
4
|
+
const BodySymbol = Symbol.for('ReqBody');
|
|
5
|
+
function useRequestBody(req) {
|
|
6
|
+
if ('body' in req) {
|
|
7
|
+
return req.body;
|
|
8
|
+
}
|
|
9
|
+
if (BodySymbol in req) {
|
|
10
|
+
return req[BodySymbol];
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
exports.useRequestBody = useRequestBody;
|
|
15
|
+
function setRequestBody(req, body) {
|
|
16
|
+
req[BodySymbol] = body;
|
|
17
|
+
}
|
|
18
|
+
exports.setRequestBody = setRequestBody;
|
|
19
|
+
//# sourceMappingURL=body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.js","sourceRoot":"","sources":["../../../src/helpers/request/body.ts"],"names":[],"mappings":";;;AAQA,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAEzC,SAAgB,cAAc,CAAC,GAAoB;IAC/C,IAAI,MAAM,IAAI,GAAG,EAAE;QACf,OAAQ,GAAW,CAAC,IAAI,CAAC;KAC5B;IAED,IAAI,UAAU,IAAI,GAAG,EAAE;QACnB,OAAQ,GAAW,CAAC,UAAU,CAAC,CAAC;KACnC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAVD,wCAUC;AAED,SAAgB,cAAc,CAAC,GAAoB,EAAE,IAAa;IAC7D,GAAW,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;AACpC,CAAC;AAFD,wCAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/cache.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAI,OAAO,CAWtF"}
|
|
@@ -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.isRequestCacheable = void 0;
|
|
10
|
+
function isRequestCacheable(req, modifiedTime) {
|
|
11
|
+
const modifiedSince = req.headers['if-modified-since'];
|
|
12
|
+
if (!modifiedSince) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
modifiedTime = typeof modifiedTime === 'string' ?
|
|
16
|
+
new Date(modifiedTime) :
|
|
17
|
+
modifiedTime;
|
|
18
|
+
return new Date(modifiedSince) >= modifiedTime;
|
|
19
|
+
}
|
|
20
|
+
exports.isRequestCacheable = isRequestCacheable;
|
|
21
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/helpers/request/cache.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,SAAgB,kBAAkB,CAAC,GAAY,EAAE,YAA2B;IACxE,MAAM,aAAa,GAAG,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACvD,IAAI,CAAC,aAAa,EAAE;QAChB,OAAO,KAAK,CAAC;KAChB;IAED,YAAY,GAAG,OAAO,YAAY,KAAK,QAAQ,CAAC,CAAC;QAC7C,IAAI,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACxB,YAAY,CAAC;IAEjB,OAAO,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,YAAY,CAAC;AACnD,CAAC;AAXD,gDAWC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/env.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAIrC,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,QAQtE;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAI,OAAO,GAAG,SAAS,CAM7E"}
|
|
@@ -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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.useRequestEnv = exports.setRequestEnv = void 0;
|
|
10
|
+
const envSymbol = Symbol.for('ReqEnv');
|
|
11
|
+
function setRequestEnv(req, key, value) {
|
|
12
|
+
if (envSymbol in req) {
|
|
13
|
+
req[envSymbol][key] = value;
|
|
14
|
+
}
|
|
15
|
+
req[envSymbol] = {
|
|
16
|
+
[key]: value,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.setRequestEnv = setRequestEnv;
|
|
20
|
+
function useRequestEnv(req, key) {
|
|
21
|
+
if (envSymbol in req) {
|
|
22
|
+
return req[envSymbol][key];
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
exports.useRequestEnv = useRequestEnv;
|
|
27
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../src/helpers/request/env.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEvC,SAAgB,aAAa,CAAC,GAAY,EAAE,GAAW,EAAE,KAAc;IACnE,IAAI,SAAS,IAAI,GAAG,EAAE;QACjB,GAAW,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;KACxC;IAEA,GAAW,CAAC,SAAS,CAAC,GAAG;QACtB,CAAC,GAAG,CAAC,EAAE,KAAK;KACf,CAAC;AACN,CAAC;AARD,sCAQC;AAED,SAAgB,aAAa,CAAC,GAAY,EAAE,GAAW;IACnD,IAAI,SAAS,IAAI,GAAG,EAAE;QAClB,OAAQ,GAAW,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC;KACvC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAND,sCAMC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
export declare function useRequestAcceptsCharsets(req: IncomingMessage): string[];
|
|
4
|
+
export declare function useRequestAcceptsCharsets(req: IncomingMessage, input: string): string | undefined;
|
|
5
|
+
export declare function useRequestAcceptsCharsets(req: IncomingMessage, input: string[]): string | undefined;
|
|
6
|
+
export declare function useRequestAcceptsCharsets(req: IncomingMessage, ...input: string[]): string | undefined;
|
|
7
|
+
//# sourceMappingURL=header-accept-charset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-accept-charset.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/header-accept-charset.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAGvC,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,eAAe,GAAI,MAAM,EAAE,CAAC;AAC3E,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAI,MAAM,GAAG,SAAS,CAAC;AACpG,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAI,MAAM,GAAG,SAAS,CAAC;AACtG,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,GAAI,MAAM,GAAG,SAAS,CAAC"}
|
|
@@ -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.useRequestAcceptsCharsets = void 0;
|
|
10
|
+
const negotiator_1 = require("./negotiator");
|
|
11
|
+
function useRequestAcceptsCharsets(req, input) {
|
|
12
|
+
input = input || [];
|
|
13
|
+
const items = Array.isArray(input) ? input : [input];
|
|
14
|
+
const negotiator = (0, negotiator_1.useRequestNegotiator)(req);
|
|
15
|
+
if (items.length === 0) {
|
|
16
|
+
return negotiator.charsets();
|
|
17
|
+
}
|
|
18
|
+
return negotiator.charsets(items).shift() || undefined;
|
|
19
|
+
}
|
|
20
|
+
exports.useRequestAcceptsCharsets = useRequestAcceptsCharsets;
|
|
21
|
+
//# sourceMappingURL=header-accept-charset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-accept-charset.js","sourceRoot":"","sources":["../../../src/helpers/request/header-accept-charset.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,6CAAoD;AAMpD,SAAgB,yBAAyB,CAAC,GAAoB,EAAE,KAAyB;IACrF,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;IACpB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAErD,MAAM,UAAU,GAAG,IAAA,iCAAoB,EAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC;KAChC;IAED,OAAO,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,SAAS,CAAC;AAC3D,CAAC;AAXD,8DAWC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
export declare function useRequestAcceptsEncodings(req: IncomingMessage): string[];
|
|
4
|
+
export declare function useRequestAcceptsEncodings(req: IncomingMessage, input: string): string | undefined;
|
|
5
|
+
export declare function useRequestAcceptsEncodings(req: IncomingMessage, input: string[]): string | undefined;
|
|
6
|
+
export declare function useRequestAcceptsEncodings(req: IncomingMessage, ...input: string[]): string | undefined;
|
|
7
|
+
//# sourceMappingURL=header-accept-encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-accept-encoding.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/header-accept-encoding.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAGvC,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,eAAe,GAAI,MAAM,EAAE,CAAC;AAC5E,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAI,MAAM,GAAG,SAAS,CAAC;AACrG,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAI,MAAM,GAAG,SAAS,CAAC;AACvG,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,GAAI,MAAM,GAAG,SAAS,CAAC"}
|
|
@@ -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.useRequestAcceptsEncodings = void 0;
|
|
10
|
+
const negotiator_1 = require("./negotiator");
|
|
11
|
+
function useRequestAcceptsEncodings(req, input) {
|
|
12
|
+
input = input || [];
|
|
13
|
+
const items = Array.isArray(input) ? input : [input];
|
|
14
|
+
const negotiator = (0, negotiator_1.useRequestNegotiator)(req);
|
|
15
|
+
if (items.length === 0) {
|
|
16
|
+
return negotiator.encodings();
|
|
17
|
+
}
|
|
18
|
+
return negotiator.encodings(items).shift() || undefined;
|
|
19
|
+
}
|
|
20
|
+
exports.useRequestAcceptsEncodings = useRequestAcceptsEncodings;
|
|
21
|
+
//# sourceMappingURL=header-accept-encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-accept-encoding.js","sourceRoot":"","sources":["../../../src/helpers/request/header-accept-encoding.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,6CAAoD;AAMpD,SAAgB,0BAA0B,CAAC,GAAoB,EAAE,KAAyB;IACtF,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;IACpB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAErD,MAAM,UAAU,GAAG,IAAA,iCAAoB,EAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO,UAAU,CAAC,SAAS,EAAE,CAAC;KACjC;IAED,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,SAAS,CAAC;AAC5D,CAAC;AAXD,gEAWC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
export declare function useRequestAcceptsLanguages(req: IncomingMessage): string[];
|
|
4
|
+
export declare function useRequestAcceptsLanguages(req: IncomingMessage, input: string): string | undefined;
|
|
5
|
+
export declare function useRequestAcceptsLanguages(req: IncomingMessage, input: string[]): string | undefined;
|
|
6
|
+
export declare function useRequestAcceptsLanguages(req: IncomingMessage, ...input: string[]): string | undefined;
|
|
7
|
+
//# sourceMappingURL=header-accept-language.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-accept-language.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/header-accept-language.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAGvC,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,eAAe,GAAI,MAAM,EAAE,CAAC;AAC5E,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAI,MAAM,GAAG,SAAS,CAAC;AACrG,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAI,MAAM,GAAG,SAAS,CAAC;AACvG,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,GAAI,MAAM,GAAG,SAAS,CAAC"}
|
|
@@ -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.useRequestAcceptsLanguages = void 0;
|
|
10
|
+
const negotiator_1 = require("./negotiator");
|
|
11
|
+
function useRequestAcceptsLanguages(req, input) {
|
|
12
|
+
input = input || [];
|
|
13
|
+
const items = Array.isArray(input) ? input : [input];
|
|
14
|
+
const negotiator = (0, negotiator_1.useRequestNegotiator)(req);
|
|
15
|
+
if (items.length === 0) {
|
|
16
|
+
return negotiator.languages();
|
|
17
|
+
}
|
|
18
|
+
return negotiator.languages(items).shift() || undefined;
|
|
19
|
+
}
|
|
20
|
+
exports.useRequestAcceptsLanguages = useRequestAcceptsLanguages;
|
|
21
|
+
//# sourceMappingURL=header-accept-language.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-accept-language.js","sourceRoot":"","sources":["../../../src/helpers/request/header-accept-language.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,6CAAoD;AAMpD,SAAgB,0BAA0B,CAAC,GAAoB,EAAE,KAAyB;IACtF,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;IACpB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAErD,MAAM,UAAU,GAAG,IAAA,iCAAoB,EAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO,UAAU,CAAC,SAAS,EAAE,CAAC;KACjC;IAED,OAAO,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,SAAS,CAAC;AAC5D,CAAC;AAXD,gEAWC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage } from 'http';
|
|
3
|
+
export declare function useRequestAccepts(req: IncomingMessage): string[];
|
|
4
|
+
export declare function useRequestAccepts(req: IncomingMessage, input: string): string | undefined;
|
|
5
|
+
export declare function useRequestAccepts(req: IncomingMessage, input: string[]): string | undefined;
|
|
6
|
+
export declare function useRequestAccepts(req: IncomingMessage, ...input: string[]): string | undefined;
|
|
7
|
+
//# sourceMappingURL=header-accept.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-accept.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/header-accept.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAKvC,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,GAAI,MAAM,EAAE,CAAC;AACnE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAI,MAAM,GAAG,SAAS,CAAC;AAC5F,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAI,MAAM,GAAG,SAAS,CAAC;AAC9F,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,GAAI,MAAM,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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.useRequestAccepts = void 0;
|
|
10
|
+
const utils_1 = require("../../utils");
|
|
11
|
+
const header_1 = require("./header");
|
|
12
|
+
const negotiator_1 = require("./negotiator");
|
|
13
|
+
function useRequestAccepts(req, input) {
|
|
14
|
+
input = input || [];
|
|
15
|
+
const items = Array.isArray(input) ? input : [input];
|
|
16
|
+
const negotiator = (0, negotiator_1.useRequestNegotiator)(req);
|
|
17
|
+
if (items.length === 0) {
|
|
18
|
+
return negotiator.mediaTypes();
|
|
19
|
+
}
|
|
20
|
+
const header = (0, header_1.getRequestHeader)(req, 'accept');
|
|
21
|
+
if (!header) {
|
|
22
|
+
return items[0];
|
|
23
|
+
}
|
|
24
|
+
let polluted = false;
|
|
25
|
+
const mimeTypes = [];
|
|
26
|
+
for (let i = 0; i < items.length; i++) {
|
|
27
|
+
const mimeType = (0, utils_1.getMimeType)(items[i]);
|
|
28
|
+
if (mimeType) {
|
|
29
|
+
mimeTypes.push(mimeType);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
polluted = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const matches = negotiator.mediaTypes(mimeTypes);
|
|
36
|
+
if (matches.length > 0) {
|
|
37
|
+
if (polluted) {
|
|
38
|
+
return items[0];
|
|
39
|
+
}
|
|
40
|
+
return items[mimeTypes.indexOf(matches[0])];
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
exports.useRequestAccepts = useRequestAccepts;
|
|
45
|
+
//# sourceMappingURL=header-accept.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-accept.js","sourceRoot":"","sources":["../../../src/helpers/request/header-accept.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,uCAA0C;AAC1C,qCAA4C;AAC5C,6CAAoD;AAMpD,SAAgB,iBAAiB,CAAC,GAAoB,EAAE,KAAyB;IAC7E,KAAK,GAAG,KAAK,IAAI,EAAE,CAAC;IACpB,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAErD,MAAM,UAAU,GAAG,IAAA,iCAAoB,EAAC,GAAG,CAAC,CAAC;IAE7C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACpB,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC;KAClC;IAED,MAAM,MAAM,GAAG,IAAA,yBAAgB,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC/C,IAAI,CAAC,MAAM,EAAE;QACT,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;KACnB;IAED,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,SAAS,GAAc,EAAE,CAAC;IAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACnC,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,IAAI,QAAQ,EAAE;YACV,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC5B;aAAM;YACH,QAAQ,GAAG,IAAI,CAAC;SACnB;KACJ;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACjD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACpB,IAAI,QAAQ,EAAE;YACV,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;SACnB;QAED,OAAO,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/C;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AApCD,8CAoCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-content-type.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/header-content-type.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAKvC,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,GAAI,OAAO,CAgB3F"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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.matchRequestContentType = void 0;
|
|
10
|
+
const constants_1 = require("../../constants");
|
|
11
|
+
const utils_1 = require("../../utils");
|
|
12
|
+
const header_1 = require("./header");
|
|
13
|
+
function matchRequestContentType(req, contentType) {
|
|
14
|
+
const header = (0, header_1.getRequestHeader)(req, constants_1.HeaderName.CONTENT_TYPE);
|
|
15
|
+
if (!header) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
/* istanbul ignore next */
|
|
19
|
+
if (Array.isArray(header)) {
|
|
20
|
+
if (header.length === 0) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return header[0] === (0, utils_1.getMimeType)(contentType);
|
|
24
|
+
}
|
|
25
|
+
return header.split('; ').shift() === (0, utils_1.getMimeType)(contentType);
|
|
26
|
+
}
|
|
27
|
+
exports.matchRequestContentType = matchRequestContentType;
|
|
28
|
+
//# sourceMappingURL=header-content-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-content-type.js","sourceRoot":"","sources":["../../../src/helpers/request/header-content-type.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,+CAA6C;AAC7C,uCAA0C;AAC1C,qCAA4C;AAE5C,SAAgB,uBAAuB,CAAC,GAAoB,EAAE,WAAmB;IAC7E,MAAM,MAAM,GAAG,IAAA,yBAAgB,EAAC,GAAG,EAAE,sBAAU,CAAC,YAAY,CAAC,CAAC;IAC9D,IAAI,CAAC,MAAM,EAAE;QACT,OAAO,IAAI,CAAC;KACf;IAED,0BAA0B;IAC1B,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACvB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,OAAO,IAAI,CAAC;SACf;QAED,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,IAAA,mBAAW,EAAC,WAAW,CAAC,CAAC;KACjD;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,IAAA,mBAAW,EAAC,WAAW,CAAC,CAAC;AACnE,CAAC;AAhBD,0DAgBC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingHttpHeaders, IncomingMessage } from 'http';
|
|
3
|
+
export declare function getRequestHeader<K extends keyof IncomingHttpHeaders>(req: IncomingMessage, name: K): IncomingHttpHeaders[K];
|
|
4
|
+
export declare function setRequestHeader<K extends keyof IncomingHttpHeaders>(req: IncomingMessage, name: K, value: IncomingHttpHeaders[K]): void;
|
|
5
|
+
//# sourceMappingURL=header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/header.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAE5D,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAChE,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,CAAC,GACP,mBAAmB,CAAC,CAAC,CAAC,CAEzB;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAChE,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,mBAAmB,CAAC,CAAC,CAAC,QAGhC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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.setRequestHeader = exports.getRequestHeader = void 0;
|
|
10
|
+
function getRequestHeader(req, name) {
|
|
11
|
+
return req.headers[name];
|
|
12
|
+
}
|
|
13
|
+
exports.getRequestHeader = getRequestHeader;
|
|
14
|
+
function setRequestHeader(req, name, value) {
|
|
15
|
+
req.headers[name] = value;
|
|
16
|
+
}
|
|
17
|
+
exports.setRequestHeader = setRequestHeader;
|
|
18
|
+
//# sourceMappingURL=header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.js","sourceRoot":"","sources":["../../../src/helpers/request/header.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,SAAgB,gBAAgB,CAC5B,GAAoB,EACpB,IAAO;IAEP,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AALD,4CAKC;AAED,SAAgB,gBAAgB,CAC5B,GAAoB,EACpB,IAAO,EACP,KAA6B;IAE7B,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AAC9B,CAAC;AAND,4CAMC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './mount-path';
|
|
2
|
+
export * from './body';
|
|
3
|
+
export * from './env';
|
|
4
|
+
export * from './header';
|
|
5
|
+
export * from './header-accept';
|
|
6
|
+
export * from './header-accept-charset';
|
|
7
|
+
export * from './header-accept-encoding';
|
|
8
|
+
export * from './header-accept-language';
|
|
9
|
+
export * from './header-content-type';
|
|
10
|
+
export * from './negotiator';
|
|
11
|
+
export * from './params';
|
|
12
|
+
export * from './path';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/request/index.ts"],"names":[],"mappings":"AAOA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 __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("./mount-path"), exports);
|
|
24
|
+
__exportStar(require("./body"), exports);
|
|
25
|
+
__exportStar(require("./env"), exports);
|
|
26
|
+
__exportStar(require("./header"), exports);
|
|
27
|
+
__exportStar(require("./header-accept"), exports);
|
|
28
|
+
__exportStar(require("./header-accept-charset"), exports);
|
|
29
|
+
__exportStar(require("./header-accept-encoding"), exports);
|
|
30
|
+
__exportStar(require("./header-accept-language"), exports);
|
|
31
|
+
__exportStar(require("./header-content-type"), exports);
|
|
32
|
+
__exportStar(require("./negotiator"), exports);
|
|
33
|
+
__exportStar(require("./params"), exports);
|
|
34
|
+
__exportStar(require("./path"), exports);
|
|
35
|
+
//# sourceMappingURL=index.js.map
|