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,58 @@
|
|
|
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.cleanDoubleSlashes = exports.withLeadingSlash = exports.withoutLeadingSlash = exports.hasLeadingSlash = exports.withTrailingSlash = exports.withoutTrailingSlash = exports.hasTrailingSlash = void 0;
|
|
10
|
+
const TRAILING_SLASH_RE = /\/$|\/\?/;
|
|
11
|
+
function hasTrailingSlash(input = '', queryParams = false) {
|
|
12
|
+
if (!queryParams) {
|
|
13
|
+
return input.endsWith('/');
|
|
14
|
+
}
|
|
15
|
+
return TRAILING_SLASH_RE.test(input);
|
|
16
|
+
}
|
|
17
|
+
exports.hasTrailingSlash = hasTrailingSlash;
|
|
18
|
+
function withoutTrailingSlash(input = '', queryParams = false) {
|
|
19
|
+
if (!queryParams) {
|
|
20
|
+
return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || '/';
|
|
21
|
+
}
|
|
22
|
+
if (!hasTrailingSlash(input, true)) {
|
|
23
|
+
return input || '/';
|
|
24
|
+
}
|
|
25
|
+
const [s0, ...s] = input.split('?');
|
|
26
|
+
return (s0.slice(0, -1) || '/') + (s.length ? `?${s.join('?')}` : '');
|
|
27
|
+
}
|
|
28
|
+
exports.withoutTrailingSlash = withoutTrailingSlash;
|
|
29
|
+
function withTrailingSlash(input = '', queryParams = false) {
|
|
30
|
+
if (!queryParams) {
|
|
31
|
+
return input.endsWith('/') ? input : (`${input}/`);
|
|
32
|
+
}
|
|
33
|
+
if (hasTrailingSlash(input, true)) {
|
|
34
|
+
return input || '/';
|
|
35
|
+
}
|
|
36
|
+
const [s0, ...s] = input.split('?');
|
|
37
|
+
return `${s0}/${s.length ? `?${s.join('?')}` : ''}`;
|
|
38
|
+
}
|
|
39
|
+
exports.withTrailingSlash = withTrailingSlash;
|
|
40
|
+
function hasLeadingSlash(input = '') {
|
|
41
|
+
return input.startsWith('/');
|
|
42
|
+
}
|
|
43
|
+
exports.hasLeadingSlash = hasLeadingSlash;
|
|
44
|
+
function withoutLeadingSlash(input = '') {
|
|
45
|
+
return (hasLeadingSlash(input) ? input.substr(1) : input) || '/';
|
|
46
|
+
}
|
|
47
|
+
exports.withoutLeadingSlash = withoutLeadingSlash;
|
|
48
|
+
function withLeadingSlash(input = '') {
|
|
49
|
+
return hasLeadingSlash(input) ? input : (`/${input}`);
|
|
50
|
+
}
|
|
51
|
+
exports.withLeadingSlash = withLeadingSlash;
|
|
52
|
+
function cleanDoubleSlashes(input = '') {
|
|
53
|
+
return input.split('://')
|
|
54
|
+
.map((str) => str.replace(/\/{2,}/g, '/'))
|
|
55
|
+
.join('://');
|
|
56
|
+
}
|
|
57
|
+
exports.cleanDoubleSlashes = cleanDoubleSlashes;
|
|
58
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAErC,SA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based routing framework.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rimraf ./dist && tsc -p tsconfig.build.json",
|
|
12
|
+
"test": "cross-env NODE_ENV=test jest --config ./test/jest.config.js",
|
|
13
|
+
"test:coverage": "cross-env NODE_ENV=test jest --config ./test/jest.config.js --coverage",
|
|
14
|
+
"lint": "eslint --ext .js,.ts ./src",
|
|
15
|
+
"lint:fix": "npm run lint -- --fix",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "Peter Placzek",
|
|
20
|
+
"email": "contact@tada5hi.net",
|
|
21
|
+
"url": "https://github.com/tada5hi"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"keywords": [
|
|
25
|
+
"api",
|
|
26
|
+
"rest",
|
|
27
|
+
"http",
|
|
28
|
+
"router",
|
|
29
|
+
"api-router",
|
|
30
|
+
"route",
|
|
31
|
+
"routing"
|
|
32
|
+
],
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/Tada5hi/routup.git"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/Tada5hi/routup/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/Tada5hi/routup#readme",
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/etag": "^1.8.1",
|
|
43
|
+
"@types/mime": "^3.0.1",
|
|
44
|
+
"@types/minimatch": "^5.1.2",
|
|
45
|
+
"@types/negotiator": "^0.6.1"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@ebec/http": "^0.0.4",
|
|
49
|
+
"cookie": "^0.5.0",
|
|
50
|
+
"etag": "^1.8.1",
|
|
51
|
+
"mime": "^3.0.0",
|
|
52
|
+
"negotiator": "^0.6.3",
|
|
53
|
+
"path-to-regexp": "^6.2.1",
|
|
54
|
+
"smob": "^0.0.6"
|
|
55
|
+
}
|
|
56
|
+
}
|