@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e22m4u/js-http-static-router",
3
- "version": "0.0.2",
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://gitrepos.ru/e22m4u/js-http-static-router",
12
+ "homepage": "https://gitverse.ru/e22m4u/js-http-static-router",
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "git+https://gitrepos.ru/e22m4u/js-http-static-router.git"
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.3.2",
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.1",
46
- "@commitlint/config-conventional": "~20.4.1",
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": "~10.1.3",
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.5.2",
57
+ "eslint-plugin-jsdoc": "~62.7.1",
58
58
  "eslint-plugin-mocha": "~11.2.0",
59
- "globals": "~17.3.0",
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.2",
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 {HttpStaticRoute} from './http-static-route.js';
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
- trailingSlash?: boolean;
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?: HttpStaticRouterOptions);
29
+ constructor(options: HttpStaticRouterOptions);
23
30
 
24
31
  /**
25
- * Add route.
32
+ * Constructor.
26
33
  *
27
- * @param remotePath
28
- * @param resourcePath
34
+ * @param container
35
+ * @param options
29
36
  */
30
- addRoute(remotePath: string, resourcePath: string): this;
37
+ constructor(container: ServiceContainer, options: HttpStaticRouterOptions);
31
38
 
32
39
  /**
33
- * Match route.
40
+ * Define route.
34
41
  *
35
- * @param req
42
+ * @param routeDef
36
43
  */
37
- matchRoute(req: IncomingMessage): HttpStaticRoute | undefined;
44
+ defineRoute(routeDef: StaticRouteDefinition): this;
38
45
 
39
46
  /**
40
- * Send file by route.
47
+ * Handle request.
41
48
  *
42
- * @param route
43
- * @param req
44
- * @param res
49
+ * @param request
50
+ * @param response
45
51
  */
46
- sendFileByRoute(
47
- route: HttpStaticRoute,
48
- req: IncomingMessage,
49
- res: ServerResponse,
50
- ): void;
52
+ handleRequest(
53
+ request: IncomingMessage,
54
+ response: ServerResponse,
55
+ ): Promise<boolean>;
51
56
  }