@e22m4u/js-http-static-router 0.0.2 → 0.1.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/README.md +35 -49
- package/dist/cjs/index.cjs +238 -209
- package/example/server.js +29 -26
- package/example/static/nested/file.txt +11 -0
- package/package.json +10 -10
- package/src/http-static-router.d.ts +27 -22
- package/src/http-static-router.js +224 -222
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/{http-static-route.d.ts → static-route.d.ts} +13 -12
- package/src/static-route.js +91 -0
- package/src/utils/get-pathname-from-url.d.ts +7 -0
- package/src/utils/get-pathname-from-url.js +27 -0
- package/src/utils/get-request-pathname.spec.js +37 -0
- package/src/utils/index.d.ts +1 -1
- package/src/utils/index.js +1 -1
- package/example/static/nested/index.html +0 -10
- package/src/http-static-route.js +0 -73
- package/src/types.d.ts +0 -38
- package/src/utils/normalize-path.d.ts +0 -12
- package/src/utils/normalize-path.js +0 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e22m4u/js-http-static-router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "HTTP-маршрутизатор статичных ресурсов для Node.js",
|
|
5
5
|
"author": "Mikhail Evstropov <e22m4u@yandex.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"router",
|
|
10
10
|
"http"
|
|
11
11
|
],
|
|
12
|
-
"homepage": "https://
|
|
12
|
+
"homepage": "https://gitverse.ru/e22m4u/js-http-static-router",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "git+https://
|
|
15
|
+
"url": "git+https://gitverse.ru/e22m4u/js-http-static-router.git"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"types": "./src/index.d.ts",
|
|
@@ -37,30 +37,30 @@
|
|
|
37
37
|
"prepare": "husky"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@e22m4u/js-format": "~0.
|
|
40
|
+
"@e22m4u/js-format": "~0.4.0",
|
|
41
41
|
"@e22m4u/js-service": "~0.5.1",
|
|
42
42
|
"mime-types": "~3.0.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@commitlint/cli": "~20.4.
|
|
46
|
-
"@commitlint/config-conventional": "~20.4.
|
|
45
|
+
"@commitlint/cli": "~20.4.3",
|
|
46
|
+
"@commitlint/config-conventional": "~20.4.3",
|
|
47
47
|
"@eslint/js": "~9.39.2",
|
|
48
48
|
"@types/chai": "~5.2.3",
|
|
49
49
|
"@types/mocha": "~10.0.10",
|
|
50
|
-
"c8": "~
|
|
50
|
+
"c8": "~11.0.0",
|
|
51
51
|
"chai": "~6.2.2",
|
|
52
52
|
"esbuild": "~0.27.3",
|
|
53
53
|
"eslint": "~9.39.2",
|
|
54
54
|
"eslint-config-prettier": "~10.1.8",
|
|
55
55
|
"eslint-plugin-chai-expect": "~3.1.0",
|
|
56
56
|
"eslint-plugin-import": "~2.32.0",
|
|
57
|
-
"eslint-plugin-jsdoc": "~62.
|
|
57
|
+
"eslint-plugin-jsdoc": "~62.7.1",
|
|
58
58
|
"eslint-plugin-mocha": "~11.2.0",
|
|
59
|
-
"globals": "~17.
|
|
59
|
+
"globals": "~17.4.0",
|
|
60
60
|
"husky": "~9.1.7",
|
|
61
61
|
"mocha": "~11.7.5",
|
|
62
62
|
"prettier": "~3.8.1",
|
|
63
|
-
"rimraf": "~6.1.
|
|
63
|
+
"rimraf": "~6.1.3",
|
|
64
64
|
"typescript": "~5.9.3"
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -1,51 +1,56 @@
|
|
|
1
1
|
import {ServerResponse} from 'node:http';
|
|
2
2
|
import {IncomingMessage} from 'node:http';
|
|
3
|
-
import {
|
|
3
|
+
import {StaticRouteDefinition} from './static-route.js';
|
|
4
4
|
import {DebuggableService, ServiceContainer} from '@e22m4u/js-service';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Http static router options.
|
|
8
8
|
*/
|
|
9
9
|
export type HttpStaticRouterOptions = {
|
|
10
|
-
|
|
11
|
-
}
|
|
10
|
+
baseDir?: string;
|
|
11
|
+
};
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Http static router.
|
|
15
15
|
*/
|
|
16
|
-
export class HttpStaticRouter extends DebuggableService {
|
|
16
|
+
export declare class HttpStaticRouter extends DebuggableService {
|
|
17
17
|
/**
|
|
18
18
|
* Constructor.
|
|
19
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* @param container
|
|
21
|
+
*/
|
|
22
|
+
constructor(container: ServiceContainer);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Constructor.
|
|
26
|
+
*
|
|
20
27
|
* @param options
|
|
21
28
|
*/
|
|
22
|
-
constructor(options
|
|
29
|
+
constructor(options: HttpStaticRouterOptions);
|
|
23
30
|
|
|
24
31
|
/**
|
|
25
|
-
*
|
|
32
|
+
* Constructor.
|
|
26
33
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
34
|
+
* @param container
|
|
35
|
+
* @param options
|
|
29
36
|
*/
|
|
30
|
-
|
|
37
|
+
constructor(container: ServiceContainer, options: HttpStaticRouterOptions);
|
|
31
38
|
|
|
32
39
|
/**
|
|
33
|
-
*
|
|
40
|
+
* Define route.
|
|
34
41
|
*
|
|
35
|
-
* @param
|
|
42
|
+
* @param routeDef
|
|
36
43
|
*/
|
|
37
|
-
|
|
44
|
+
defineRoute(routeDef: StaticRouteDefinition): this;
|
|
38
45
|
|
|
39
46
|
/**
|
|
40
|
-
*
|
|
47
|
+
* Handle request.
|
|
41
48
|
*
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @param res
|
|
49
|
+
* @param request
|
|
50
|
+
* @param response
|
|
45
51
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
): void;
|
|
52
|
+
handleRequest(
|
|
53
|
+
request: IncomingMessage,
|
|
54
|
+
response: ServerResponse,
|
|
55
|
+
): Promise<boolean>;
|
|
51
56
|
}
|