@e22m4u/ts-rest-router 0.1.1 → 0.2.0

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.
Files changed (140) hide show
  1. package/README.md +118 -118
  2. package/dist/cjs/index.cjs +346 -360
  3. package/dist/esm/controller-registry.js +28 -28
  4. package/dist/esm/debuggable-service.d.ts +10 -1
  5. package/dist/esm/debuggable-service.js +14 -3
  6. package/dist/esm/decorators/after-action/after-action-decorator.d.ts +9 -0
  7. package/dist/esm/decorators/{after/after-decorator.js → after-action/after-action-decorator.js} +7 -7
  8. package/dist/esm/decorators/{before/before-decorator.spec.js → after-action/after-action-decorator.spec.js} +19 -19
  9. package/dist/esm/decorators/{after/after-metadata.d.ts → after-action/after-action-metadata.d.ts} +4 -4
  10. package/dist/esm/decorators/after-action/after-action-metadata.js +5 -0
  11. package/dist/esm/decorators/{after/after-reflector.d.ts → after-action/after-action-reflector.d.ts} +5 -5
  12. package/dist/esm/decorators/{before/before-reflector.js → after-action/after-action-reflector.js} +6 -6
  13. package/dist/esm/decorators/{before/before-reflector.spec.js → after-action/after-action-reflector.spec.js} +23 -23
  14. package/dist/esm/decorators/after-action/index.d.ts +3 -0
  15. package/dist/esm/decorators/after-action/index.js +3 -0
  16. package/dist/esm/decorators/before-action/before-action-decorator.d.ts +9 -0
  17. package/dist/esm/decorators/{before/before-decorator.js → before-action/before-action-decorator.js} +7 -7
  18. package/dist/esm/decorators/{after/after-decorator.spec.js → before-action/before-action-decorator.spec.js} +19 -19
  19. package/dist/esm/decorators/{before/before-metadata.d.ts → before-action/before-action-metadata.d.ts} +4 -4
  20. package/dist/esm/decorators/before-action/before-action-metadata.js +5 -0
  21. package/dist/esm/decorators/{before/before-reflector.d.ts → before-action/before-action-reflector.d.ts} +5 -5
  22. package/dist/esm/decorators/{after/after-reflector.js → before-action/before-action-reflector.js} +6 -6
  23. package/dist/esm/decorators/{after/after-reflector.spec.js → before-action/before-action-reflector.spec.js} +23 -23
  24. package/dist/esm/decorators/before-action/index.d.ts +3 -0
  25. package/dist/esm/decorators/before-action/index.js +3 -0
  26. package/dist/esm/decorators/index.d.ts +4 -4
  27. package/dist/esm/decorators/index.js +4 -4
  28. package/dist/esm/decorators/request-context/request-context-decorator.d.ts +4 -4
  29. package/dist/esm/decorators/request-context/request-context-decorator.js +4 -4
  30. package/dist/esm/decorators/request-context/request-context-decorator.spec.js +6 -0
  31. package/dist/esm/decorators/request-data/request-data-decorator.d.ts +10 -10
  32. package/dist/esm/decorators/request-data/request-data-decorator.js +10 -10
  33. package/dist/esm/decorators/request-data/request-data-decorator.spec.js +44 -32
  34. package/dist/esm/decorators/request-data/request-data-metadata.d.ts +1 -1
  35. package/dist/esm/decorators/rest-action/index.d.ts +3 -0
  36. package/dist/esm/decorators/rest-action/index.js +3 -0
  37. package/dist/esm/decorators/rest-action/rest-action-decorator.d.ts +57 -0
  38. package/dist/esm/decorators/rest-action/rest-action-decorator.js +52 -0
  39. package/dist/esm/decorators/rest-action/rest-action-decorator.spec.js +401 -0
  40. package/dist/esm/decorators/{action/action-metadata.d.ts → rest-action/rest-action-metadata.d.ts} +6 -6
  41. package/dist/esm/decorators/rest-action/rest-action-metadata.js +5 -0
  42. package/dist/esm/decorators/rest-action/rest-action-reflector.d.ts +22 -0
  43. package/dist/esm/decorators/{action/action-reflector.js → rest-action/rest-action-reflector.js} +6 -6
  44. package/dist/esm/decorators/{action/action-reflector.spec.js → rest-action/rest-action-reflector.spec.js} +13 -13
  45. package/dist/esm/decorators/rest-controller/index.d.ts +3 -0
  46. package/dist/esm/decorators/rest-controller/index.js +3 -0
  47. package/dist/esm/decorators/rest-controller/rest-controller-decorator.d.ts +14 -0
  48. package/dist/esm/decorators/{controller/controller-decorator.js → rest-controller/rest-controller-decorator.js} +5 -5
  49. package/dist/esm/decorators/{controller/controller-decorator.spec.js → rest-controller/rest-controller-decorator.spec.js} +15 -15
  50. package/dist/esm/decorators/{controller/controller-metadata.d.ts → rest-controller/rest-controller-metadata.d.ts} +5 -5
  51. package/dist/esm/decorators/rest-controller/rest-controller-metadata.js +5 -0
  52. package/dist/esm/decorators/rest-controller/rest-controller-reflector.d.ts +20 -0
  53. package/dist/esm/decorators/rest-controller/rest-controller-reflector.js +24 -0
  54. package/dist/esm/decorators/{controller/controller-reflector.spec.js → rest-controller/rest-controller-reflector.spec.js} +12 -12
  55. package/dist/esm/errors/not-a-controller-error.js +1 -1
  56. package/dist/esm/types.d.ts +0 -10
  57. package/dist/esm/utils/index.d.ts +0 -1
  58. package/dist/esm/utils/index.js +0 -1
  59. package/package.json +19 -19
  60. package/src/controller-registry.spec.ts +122 -122
  61. package/src/controller-registry.ts +33 -35
  62. package/src/debuggable-service.ts +17 -4
  63. package/src/decorators/{after/after-decorator.spec.ts → after-action/after-action-decorator.spec.ts} +19 -19
  64. package/src/decorators/{before/before-decorator.ts → after-action/after-action-decorator.ts} +9 -9
  65. package/src/decorators/{after/after-metadata.ts → after-action/after-action-metadata.ts} +5 -5
  66. package/src/decorators/{before/before-reflector.spec.ts → after-action/after-action-reflector.spec.ts} +33 -23
  67. package/src/decorators/{before/before-reflector.ts → after-action/after-action-reflector.ts} +13 -9
  68. package/src/decorators/after-action/index.ts +3 -0
  69. package/src/decorators/{before/before-decorator.spec.ts → before-action/before-action-decorator.spec.ts} +19 -19
  70. package/src/decorators/{after/after-decorator.ts → before-action/before-action-decorator.ts} +9 -9
  71. package/src/decorators/before-action/before-action-metadata.ts +17 -0
  72. package/src/decorators/{after/after-reflector.spec.ts → before-action/before-action-reflector.spec.ts} +40 -23
  73. package/src/decorators/{after/after-reflector.ts → before-action/before-action-reflector.ts} +18 -9
  74. package/src/decorators/before-action/index.ts +3 -0
  75. package/src/decorators/index.ts +4 -4
  76. package/src/decorators/request-context/request-context-decorator.spec.ts +7 -0
  77. package/src/decorators/request-context/request-context-decorator.ts +4 -4
  78. package/src/decorators/request-data/request-data-decorator.spec.ts +45 -32
  79. package/src/decorators/request-data/request-data-decorator.ts +10 -10
  80. package/src/decorators/request-data/request-data-metadata.ts +1 -1
  81. package/src/decorators/rest-action/index.ts +3 -0
  82. package/src/decorators/rest-action/rest-action-decorator.spec.ts +325 -0
  83. package/src/decorators/rest-action/rest-action-decorator.ts +166 -0
  84. package/src/decorators/{action/action-metadata.ts → rest-action/rest-action-metadata.ts} +7 -7
  85. package/src/decorators/{action/action-reflector.spec.ts → rest-action/rest-action-reflector.spec.ts} +13 -13
  86. package/src/decorators/rest-action/rest-action-reflector.ts +41 -0
  87. package/src/decorators/rest-controller/index.ts +3 -0
  88. package/src/decorators/{controller/controller-decorator.spec.ts → rest-controller/rest-controller-decorator.spec.ts} +16 -16
  89. package/src/decorators/{controller/controller-decorator.ts → rest-controller/rest-controller-decorator.ts} +14 -10
  90. package/src/decorators/{controller/controller-metadata.ts → rest-controller/rest-controller-metadata.ts} +6 -7
  91. package/src/decorators/{controller/controller-reflector.spec.ts → rest-controller/rest-controller-reflector.spec.ts} +21 -12
  92. package/src/decorators/rest-controller/rest-controller-reflector.ts +32 -0
  93. package/src/errors/not-a-controller-error.ts +4 -1
  94. package/src/types.ts +0 -10
  95. package/src/utils/index.ts +0 -1
  96. package/README-ru.md +0 -268
  97. package/dist/esm/decorators/action/action-decorator.d.ts +0 -52
  98. package/dist/esm/decorators/action/action-decorator.js +0 -62
  99. package/dist/esm/decorators/action/action-decorator.spec.js +0 -59
  100. package/dist/esm/decorators/action/action-metadata.js +0 -5
  101. package/dist/esm/decorators/action/action-reflector.d.ts +0 -22
  102. package/dist/esm/decorators/action/index.d.ts +0 -3
  103. package/dist/esm/decorators/action/index.js +0 -3
  104. package/dist/esm/decorators/after/after-decorator.d.ts +0 -9
  105. package/dist/esm/decorators/after/after-metadata.js +0 -5
  106. package/dist/esm/decorators/after/index.d.ts +0 -3
  107. package/dist/esm/decorators/after/index.js +0 -3
  108. package/dist/esm/decorators/before/before-decorator.d.ts +0 -9
  109. package/dist/esm/decorators/before/before-metadata.js +0 -5
  110. package/dist/esm/decorators/before/index.d.ts +0 -3
  111. package/dist/esm/decorators/before/index.js +0 -3
  112. package/dist/esm/decorators/controller/controller-decorator.d.ts +0 -14
  113. package/dist/esm/decorators/controller/controller-metadata.js +0 -5
  114. package/dist/esm/decorators/controller/controller-reflector.d.ts +0 -20
  115. package/dist/esm/decorators/controller/controller-reflector.js +0 -24
  116. package/dist/esm/decorators/controller/index.d.ts +0 -3
  117. package/dist/esm/decorators/controller/index.js +0 -3
  118. package/dist/esm/utils/create-debugger.d.ts +0 -44
  119. package/dist/esm/utils/create-debugger.js +0 -81
  120. package/dist/esm/utils/create-debugger.spec.d.ts +0 -1
  121. package/dist/esm/utils/create-debugger.spec.js +0 -8
  122. package/src/decorators/action/action-decorator.spec.ts +0 -42
  123. package/src/decorators/action/action-decorator.ts +0 -98
  124. package/src/decorators/action/action-reflector.ts +0 -38
  125. package/src/decorators/action/index.ts +0 -3
  126. package/src/decorators/after/index.ts +0 -3
  127. package/src/decorators/before/before-metadata.ts +0 -17
  128. package/src/decorators/before/index.ts +0 -3
  129. package/src/decorators/controller/controller-reflector.ts +0 -28
  130. package/src/decorators/controller/index.ts +0 -3
  131. package/src/utils/create-debugger.spec.ts +0 -9
  132. package/src/utils/create-debugger.ts +0 -98
  133. /package/dist/esm/decorators/{action/action-decorator.spec.d.ts → after-action/after-action-decorator.spec.d.ts} +0 -0
  134. /package/dist/esm/decorators/{action/action-reflector.spec.d.ts → after-action/after-action-reflector.spec.d.ts} +0 -0
  135. /package/dist/esm/decorators/{after/after-decorator.spec.d.ts → before-action/before-action-decorator.spec.d.ts} +0 -0
  136. /package/dist/esm/decorators/{after/after-reflector.spec.d.ts → before-action/before-action-reflector.spec.d.ts} +0 -0
  137. /package/dist/esm/decorators/{before/before-decorator.spec.d.ts → rest-action/rest-action-decorator.spec.d.ts} +0 -0
  138. /package/dist/esm/decorators/{before/before-reflector.spec.d.ts → rest-action/rest-action-reflector.spec.d.ts} +0 -0
  139. /package/dist/esm/decorators/{controller/controller-decorator.spec.d.ts → rest-controller/rest-controller-decorator.spec.d.ts} +0 -0
  140. /package/dist/esm/decorators/{controller/controller-reflector.spec.d.ts → rest-controller/rest-controller-reflector.spec.d.ts} +0 -0
package/README.md CHANGED
@@ -1,27 +1,25 @@
1
1
  # @e22m4u/ts-rest-router
2
2
 
3
- *English | [Русский](./README-ru.md)*
3
+ REST маршрутизатор на основе контроллеров для TypeScript.
4
4
 
5
- Controllers-based REST router implementation for TypeScript.
5
+ #### Основные возможности
6
6
 
7
- #### Key Features
7
+ - Декларативное определение маршрутов через декораторы.
8
+ - Типизированные параметры запросов (body, query, params).
9
+ - Поддержка middleware до и после обработки запроса.
10
+ - Валидация входящих данных.
11
+ - Поддержка всех HTTP методов (GET, POST, PUT, PATCH и DELETE).
8
12
 
9
- - Declarative route definition using decorators.
10
- - Typed request parameters (body, query, params).
11
- - Pre and post request middleware support.
12
- - Input data validation.
13
- - Support for all HTTP methods (GET, POST, PUT, DELETE, etc.).
14
-
15
- ## Installation
13
+ ## Установка
16
14
 
17
15
  ```bash
18
16
  npm install @e22m4u/ts-rest-router
19
17
  ```
20
18
 
21
- #### Decorators support
19
+ #### Поддержка декораторов
22
20
 
23
- To enable decorators support add the following
24
- options to your `tsconfig.json` file.
21
+ Для включения поддержки декораторов, добавьте указанные
22
+ ниже опции в файл `tsconfig.json` вашего проекта.
25
23
 
26
24
  ```json
27
25
  {
@@ -30,152 +28,154 @@ options to your `tsconfig.json` file.
30
28
  }
31
29
  ```
32
30
 
33
- ## Basic Usage
31
+ ## Базовое использование
34
32
 
35
- Creating a controller and methods.
33
+ Создание контроллера и методов.
36
34
 
37
35
  ```ts
38
- import {get} from '@e22m4u/ts-rest-router';
39
- import {post} from '@e22m4u/ts-rest-router';
40
- import {field} from '@e22m4u/ts-rest-router';
41
36
  import {DataType} from '@e22m4u/ts-rest-router';
42
- import {controller} from '@e22m4u/ts-rest-router';
43
-
44
- @controller('/users') // controller path
45
- class UserController { // controller class
46
- @post('/login') // POST /users/login method
37
+ import {getAction} from '@e22m4u/ts-rest-router';
38
+ import {postAction} from '@e22m4u/ts-rest-router';
39
+ import {requestField} from '@e22m4u/ts-rest-router';
40
+ import {restController} from '@e22m4u/ts-rest-router';
41
+
42
+ @restController('/users') // путь контроллера
43
+ class UserController { // класс контроллера
44
+ @postAction('/login') // метод POST /users/login
47
45
  async login(
48
- @field('username', { // "username" is request body field
49
- type: DataType.STRING, // parameter type allows only strings
50
- required: true, // parameter is required
46
+ @requestField('username', { // поле "username" в теле запроса
47
+ type: DataType.STRING, // тип параметра допускает только строки
48
+ required: true, // параметр является обязательным
51
49
  })
52
50
  username: string,
53
- @field('password', { // "password" is request body field
54
- type: DataType.STRING, // parameter type allows only strings
55
- required: true, // parameter is required
51
+ @requestField('password', { // поле "password" в теле запроса
52
+ type: DataType.STRING, // тип параметра допускает только строки
53
+ required: true, // параметр является обязательным
56
54
  })
57
55
  password: string,
58
56
  ) {
59
- return { // if method returns an object,
60
- id: '123', // the result will be presented as
61
- firstName: 'John', // "Content-Type: application/json"
57
+ return { // если метод возвращает объект,
58
+ id: '123', // то результат будет представлен как
59
+ firstName: 'John', // "Content-Type: application/json"
62
60
  lastName: 'Doe',
63
61
  };
64
62
  }
65
63
  }
66
64
  ```
67
65
 
68
- Registering controllers and starting the server.
66
+ Регистрация контроллеров и запуск сервера.
69
67
 
70
68
  ```ts
71
69
  import http from 'http';
72
70
  import {RestRouter} from '@e22m4u/ts-rest-router';
73
71
 
74
- // create router and register controllers
72
+ // создание маршрутизатора и регистрация контроллеров
75
73
  const router = new RestRouter();
76
74
  router.registerController(UserController);
77
75
  router.registerController(ProductController);
78
76
 
79
- // create server and register request handler
77
+ // создание сервера и регистрация обработчика запросов
80
78
  const server = new http.Server();
81
79
  server.on('request', router.requestListener);
82
80
 
83
- // start server
81
+ // запуск сервера
84
82
  server.listen('8080', '0.0.0.0', () => {
85
83
  console.log(`Server is running on http://localhost:8080`);
86
84
  });
87
85
  ```
88
86
 
89
- ## Decorators
87
+ ## Декораторы
90
88
 
91
- Controller and methods:
89
+ Контроллер и методы:
92
90
 
93
- - `@controller` - defines a class as a controller
94
- - `@action` - base decorator for methods
95
- - `@get` - GET requests
96
- - `@post` - POST requests
97
- - `@put` - PUT requests
98
- - `@patch` - PATCH requests
99
- - `@del` - DELETE requests
91
+ - `@restController` - определяет класс как контроллер;
92
+ - `@restAction` - базовый декоратор для методов;
93
+ - `@getAction` - метод GET;
94
+ - `@postAction` - метод POST;
95
+ - `@putAction` - метод PUT;
96
+ - `@patchAction` - метод PATCH;
97
+ - `@deleteAction` - метод DELETE;
100
98
 
101
- Request hooks:
99
+ Хуки запроса:
102
100
 
103
- - `@before` - middleware before request handling
104
- - `@after` - middleware after request handling
101
+ - `@beforeAction` - middleware перед обработкой запроса;
102
+ - `@afterAction` - middleware после обработки запроса;
105
103
 
106
- Request parameters:
104
+ Параметры запроса:
107
105
 
108
- - `@param` - single URL parameter
109
- - `@params` - all URL parameters as an object
110
- - `@query` - single query parameter
111
- - `@queries` - all query parameters as an object
112
- - `@body` - request body
113
- - `@field` - field in request body
114
- - `@header` - single header
115
- - `@headers` - all headers as an object
116
- - `@cookie` - single cookie
117
- - `@cookies` - all cookies as an object
118
- - `@requestContext` - access to request context
119
- - `@requestData` - universal decorator for accessing request data
106
+ - `@requestParam` - определенный URL параметр;
107
+ - `@requestParams` - все параметры URL как объект;
108
+ - `@requestQuery` - определенный query параметр;
109
+ - `@requestQueries` - все query параметры как объект;
110
+ - `@requestBody` - тело запроса;
111
+ - `@requestField` - поле в теле запроса;
112
+ - `@requestHeader` - определенный заголовок запроса;
113
+ - `@requestHeaders` - все заголовки запроса как объект;
114
+ - `@requestCookie` - определенный cookie запроса;
115
+ - `@requestCookies` - все cookies запроса как объект;
116
+ - `@requestContext` - доступ к контексту запроса;
117
+ - `@requestData` - доступ к данным запроса;
118
+ - `@httpRequest` - экземпляр `IncomingMessage`;
119
+ - `@httpResponse` - экземпляр `ServerResponse`;
120
120
 
121
- #### `@controller(options?: ControllerOptions)`
121
+ #### `@restController(options?: ControllerOptions)`
122
122
 
123
- Defining a controller.
123
+ Определение контроллера.
124
124
 
125
125
  ```ts
126
- @controller()
126
+ @restController()
127
127
  class UserController {
128
- // controller methods
128
+ // методы контроллера
129
129
  }
130
130
  ```
131
131
 
132
- Defining controller path.
132
+ Определение пути контроллера.
133
133
 
134
134
  ```ts
135
- @controller('/users') // controller path
135
+ @restController('/users') // путь контроллера
136
136
  class UserController {
137
- // controller methods
137
+ // методы контроллера
138
138
  }
139
139
  ```
140
140
 
141
- Additional decorator parameters.
141
+ Дополнительные параметры декоратора.
142
142
 
143
143
  ```ts
144
- @controller({
145
- path: '/api', // controller path
146
- before: [authMiddleware], // middleware before request processing
147
- after: [loggerMiddleware], // middleware after request processing
144
+ @restController({
145
+ path: '/api', // путь контроллера
146
+ before: [authMiddleware], // middleware до обработки запроса
147
+ after: [loggerMiddleware], // middleware после обработки запроса
148
148
  })
149
149
  class UserController {
150
- // controller methods
150
+ // методы контроллера
151
151
  }
152
152
  ```
153
153
 
154
- #### `@get(path: string, options?: ActionOptions)`
154
+ #### `@getAction(path: string, options?: ActionOptions)`
155
155
 
156
- Defining GET method.
156
+ Определение метода GET.
157
157
 
158
158
  ```ts
159
- @controller('/users') // controller path
160
- class UserController { // controller class
161
- @get('/whoAmI') // GET /users/whoAmI route
159
+ @restController('/users') // путь контроллера
160
+ class UserController { // класс контроллера
161
+ @getAction('/whoAmI') // маршрут GET /users/whoAmI
162
162
  async whoAmI() {
163
- return { // if method returns an object,
164
- name: 'John', // the result will be presented
165
- surname: 'Doe', // as "Content-Type: application/json"
163
+ return { // если метод возвращает объект,
164
+ name: 'John', // то результат будет представлен
165
+ surname: 'Doe', // как "Content-Type: application/json"
166
166
  };
167
167
  }
168
168
  }
169
169
  ```
170
170
 
171
- Additional decorator parameters.
171
+ Дополнительные параметры декоратора.
172
172
 
173
173
  ```ts
174
- @controller('/users') // controller path
175
- class UserController { // controller class
176
- @get('/whoAmI', { // GET /users/whoAmI route
177
- before: [authMiddleware], // middleware before request processing
178
- after: [loggerMiddleware], // middleware after request processing
174
+ @restController('/users') // путь контроллера
175
+ class UserController { // класс контроллера
176
+ @getAction('/whoAmI', { // маршрут GET /users/whoAmI
177
+ before: [authMiddleware], // middleware до обработки запроса
178
+ after: [loggerMiddleware], // middleware после обработки запроса
179
179
  })
180
180
  async whoAmI() {
181
181
  return {
@@ -188,17 +188,17 @@ class UserController { // controller class
188
188
 
189
189
  #### `@requestContext(propertyName?: string)`
190
190
 
191
- Access to request context.
191
+ Доступ к контексту запроса.
192
192
 
193
193
  ```ts
194
194
  import {RequestContext} from '@e22m4u/js-trie-router';
195
195
 
196
- @controller('/users') // controller path
197
- class UserController { // controller class
198
- @get('/:id') // GET /users/:id route
196
+ @restController('/users') // путь контроллера
197
+ class UserController { // класс контроллера
198
+ @getAction('/:id') // маршрут GET /users/:id
199
199
  findById(
200
- @requestContext() // including request context
201
- ctx: RequestContext, // as method parameter
200
+ @requestContext() // включениее контекста запроса
201
+ ctx: RequestContext, // в качестве параметра метода
202
202
  ) {
203
203
  console.log(ctx.req); // IncomingMessage
204
204
  console.log(ctx.res); // ServerResponse
@@ -214,20 +214,20 @@ class UserController { // controller class
214
214
  }
215
215
  ```
216
216
 
217
- Access to context properties.
217
+ Доступ к свойствам контекста.
218
218
 
219
219
  ```ts
220
220
  import {ServerResponse} from 'http';
221
221
  import {IncomingMessage} from 'http';
222
222
 
223
- @controller('/users') // controller path
224
- class UserController { // controller class
225
- @get('/:id') // GET /users/:id route
223
+ @restController('/users') // путь контроллера
224
+ class UserController { // класс контроллера
225
+ @getAction('/:id') // маршрут GET /users/:id
226
226
  findById(
227
- @requestContext('req') // request context decorator
228
- req: IncomingMessage, // including "req" property
229
- @requestContext('res') // request context decorator
230
- res: ServerResponse, // including "res" property
227
+ @requestContext('req') // декоратор контекста запроса
228
+ req: IncomingMessage, // включающий свойство "req"
229
+ @requestContext('res') // декоратор контекста запроса
230
+ res: ServerResponse, // включающий свойство "res"
231
231
  ) {
232
232
  console.log(req); // IncomingMessage
233
233
  console.log(res); // ServerResponse
@@ -235,34 +235,34 @@ class UserController { // controller class
235
235
  }
236
236
  ```
237
237
 
238
- Context properties:
238
+ Свойства контекста:
239
239
 
240
- - `container: ServiceContainer` instance of [service container](https://npmjs.com/package/@e22m4u/js-service)
241
- - `req: IncomingMessage` native incoming request stream
242
- - `res: ServerResponse` native server response stream
243
- - `params: ParsedParams` key-value object with path parameters
244
- - `query: ParsedQuery` key-value object with query string parameters
245
- - `headers: ParsedHeaders` key-value object with request headers
246
- - `cookie: ParsedCookie` key-value object of parsed `cookie` header
247
- - `method: string` request method in uppercase, e.g. `GET`, `POST`, etc.
248
- - `path: string` path including query string, e.g. `/myPath?foo=bar`
249
- - `pathname: string` request path, e.g. `/myMath`
250
- - `body: unknown` request body
240
+ - `container: ServiceContainer` экземпляр [сервис-контейнера](https://npmjs.com/package/@e22m4u/js-service)
241
+ - `req: IncomingMessage` нативный поток входящего запроса
242
+ - `res: ServerResponse` нативный поток ответа сервера
243
+ - `params: ParsedParams` объект ключ-значение с параметрами пути
244
+ - `query: ParsedQuery` объект ключ-значение с параметрами строки запроса
245
+ - `headers: ParsedHeaders` объект ключ-значение с заголовками запроса
246
+ - `cookie: ParsedCookie` объект ключ-значение разобранного заголовка `cookie`
247
+ - `method: string` метод запроса в верхнем регистре, например `GET`, `POST` и т.д.
248
+ - `path: string` путь включающий строку запроса, например `/myPath?foo=bar`
249
+ - `pathname: string` путь запроса, например `/myMath`
250
+ - `body: unknown` тело запроса
251
251
 
252
- ## Debugging
252
+ ## Отладка
253
253
 
254
- Set the `DEBUG` variable to enable log output.
254
+ Установка переменной `DEBUG` включает вывод логов.
255
255
 
256
256
  ```bash
257
257
  DEBUG=tsRestRouter* npm run test
258
258
  ```
259
259
 
260
- ## Tests
260
+ ## Тесты
261
261
 
262
262
  ```bash
263
263
  npm run test
264
264
  ```
265
265
 
266
- ## License
266
+ ## Лицензия
267
267
 
268
268
  MIT