@rapidrest/service-core 1.0.0-beta.1 → 1.0.0-beta.2
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/dist/lib/auth/AuthMiddleware.js +33 -3
- package/dist/lib/auth/AuthMiddleware.js.map +1 -1
- package/dist/lib/auth/BasicStrategy.js +46 -39
- package/dist/lib/auth/BasicStrategy.js.map +1 -1
- package/dist/lib/auth/JWTStrategy.js +69 -60
- package/dist/lib/auth/JWTStrategy.js.map +1 -1
- package/dist/lib/index.js +2 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/routes/RouteUtils.js +8 -7
- package/dist/lib/routes/RouteUtils.js.map +1 -1
- package/dist/types/auth/AuthMiddleware.d.ts +12 -1
- package/dist/types/auth/AuthStrategy.d.ts +13 -1
- package/dist/types/auth/BasicStrategy.d.ts +7 -3
- package/dist/types/auth/JWTStrategy.d.ts +6 -3
- package/dist/types/index.d.ts +2 -1
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +1 -1
- package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +7 -7
- package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +1 -1
- package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +1 -1
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +5 -5
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +3 -3
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +3 -3
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +1 -1
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +4 -4
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +5 -5
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +4 -4
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +5 -5
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +1 -1
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +1 -1
- package/docs/reference/classes/ACLUtils.md +10 -10
- package/docs/reference/classes/AdminRoute.md +3 -3
- package/docs/reference/classes/AuthMiddleware.md +55 -13
- package/docs/reference/classes/BackgroundService.md +8 -8
- package/docs/reference/classes/BackgroundServiceManager.md +7 -7
- package/docs/reference/classes/BaseEntity.md +6 -6
- package/docs/reference/classes/BaseMongoEntity.md +7 -7
- package/docs/reference/classes/BasicStrategy.md +52 -10
- package/docs/reference/classes/BasicStrategyOptions.md +35 -11
- package/docs/reference/classes/BulkError.md +3 -3
- package/docs/reference/classes/ConnectionManager.md +4 -4
- package/docs/reference/classes/EventListenerManager.md +5 -5
- package/docs/reference/classes/HttpRouter.md +343 -0
- package/docs/reference/classes/JWTStrategy.md +37 -14
- package/docs/reference/classes/JWTStrategyOptions.md +10 -10
- package/docs/reference/classes/MetricsRoute.md +2 -2
- package/docs/reference/classes/ModelRoute.md +28 -28
- package/docs/reference/classes/ModelUtils.md +10 -10
- package/docs/reference/classes/MongoConnection.md +12 -12
- package/docs/reference/classes/MongoRepository.md +17 -17
- package/docs/reference/classes/MongoSchemaSync.md +3 -3
- package/docs/reference/classes/NetUtils.md +4 -4
- package/docs/reference/classes/NotificationUtils.md +3 -3
- package/docs/reference/classes/ObjectFactory.md +10 -10
- package/docs/reference/classes/OpenAPIRoute.md +5 -5
- package/docs/reference/classes/OpenApiSpec.md +45 -45
- package/docs/reference/classes/RecoverableBaseEntity.md +7 -7
- package/docs/reference/classes/RecoverableBaseMongoEntity.md +8 -8
- package/docs/reference/classes/RedisTransport.md +4 -4
- package/docs/reference/classes/RepoUtils.md +28 -28
- package/docs/reference/classes/RouteUtils.md +17 -17
- package/docs/reference/classes/Server.md +29 -29
- package/docs/reference/classes/SimpleEntity.md +3 -3
- package/docs/reference/classes/SimpleMongoEntity.md +4 -4
- package/docs/reference/classes/StatusExtraData.md +4 -4
- package/docs/reference/classes/StatusRoute.md +1 -1
- package/docs/reference/classes/UWSRequest.md +226 -0
- package/docs/reference/classes/UWSResponse.md +257 -0
- package/docs/reference/classes/UWSWebSocketShim.md +958 -0
- package/docs/reference/enumerations/ACLAction.md +7 -7
- package/docs/reference/enumerations/ApiErrorMessages.md +15 -15
- package/docs/reference/enumerations/ApiErrors.md +15 -15
- package/docs/reference/functions/createWebSocketStream.md +27 -0
- package/docs/reference/functions/isSqlDataSource.md +1 -1
- package/docs/reference/functions/readBody.md +29 -0
- package/docs/reference/functions/resolveCollectionName.md +1 -1
- package/docs/reference/functions/runChain.md +40 -0
- package/docs/reference/functions/snakeCase.md +1 -1
- package/docs/reference/globals.md +15 -0
- package/docs/reference/interfaces/ACLRecord.md +8 -8
- package/docs/reference/interfaces/AccessControlList.md +5 -5
- package/docs/reference/interfaces/AuthResult.md +5 -5
- package/docs/reference/interfaces/AuthStrategy.md +47 -9
- package/docs/reference/interfaces/CreateRequestOptions.md +11 -11
- package/docs/reference/interfaces/DeleteRequestOptions.md +13 -13
- package/docs/reference/interfaces/FindRequestOptions.md +12 -12
- package/docs/reference/interfaces/HttpRequest.md +147 -0
- package/docs/reference/interfaces/HttpResponse.md +164 -0
- package/docs/reference/interfaces/JWTAuthResult.md +9 -9
- package/docs/reference/interfaces/RepoCreateOptions.md +7 -7
- package/docs/reference/interfaces/RepoDeleteOptions.md +9 -9
- package/docs/reference/interfaces/RepoFindOptions.md +11 -11
- package/docs/reference/interfaces/RepoOperationOptions.md +6 -6
- package/docs/reference/interfaces/RepoUpdateOptions.md +8 -8
- package/docs/reference/interfaces/RequestOptions.md +10 -10
- package/docs/reference/interfaces/RequestWS.md +225 -0
- package/docs/reference/interfaces/TruncateRequestOptions.md +15 -15
- package/docs/reference/interfaces/UpdateRequestOptions.md +13 -13
- package/docs/reference/type-aliases/ErrorHandler.md +35 -0
- package/docs/reference/type-aliases/NextFunction.md +23 -0
- package/docs/reference/type-aliases/OneOrMany.md +1 -1
- package/docs/reference/type-aliases/OneOrNull.md +1 -1
- package/docs/reference/type-aliases/PartialBaseEntity.md +1 -1
- package/docs/reference/type-aliases/PartialSimpleEntity.md +1 -1
- package/docs/reference/type-aliases/RequestHandler.md +31 -0
- package/docs/reference/type-aliases/UpdateObject.md +1 -1
- package/docs/reference/type-aliases/WsUpgradeAuth.md +27 -0
- package/docs/reference/type-aliases/WsUpgradeAuthResult.md +47 -0
- package/package.json +2 -2
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
[**@rapidrest/service-core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/service-core](../globals.md) / HttpRouter
|
|
6
|
+
|
|
7
|
+
# Class: HttpRouter
|
|
8
|
+
|
|
9
|
+
Defined in: [src/http/Router.ts:214](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L214)
|
|
10
|
+
|
|
11
|
+
Thin Express-compatible wrapper over `uWS.TemplatedApp`.
|
|
12
|
+
|
|
13
|
+
Provides the same `app.get()`, `app.post()`, `app.use()`, etc. API that
|
|
14
|
+
`RouteUtils.registerRoute()` uses, so no changes are needed in route registration
|
|
15
|
+
code. Global middleware registered via `use()` is prepended to every route's chain.
|
|
16
|
+
|
|
17
|
+
Also supports:
|
|
18
|
+
- `ws(path, handlers)` — native uWS WebSocket routing
|
|
19
|
+
- `static(basePath)` — basic static file serving
|
|
20
|
+
- `listen(host, port)` / `close()` — server lifecycle
|
|
21
|
+
|
|
22
|
+
## Indexable
|
|
23
|
+
|
|
24
|
+
> \[`key`: `string`\]: `any`
|
|
25
|
+
|
|
26
|
+
## Constructors
|
|
27
|
+
|
|
28
|
+
### Constructor
|
|
29
|
+
|
|
30
|
+
> **new HttpRouter**(`uwsApp`): `HttpRouter`
|
|
31
|
+
|
|
32
|
+
Defined in: [src/http/Router.ts:226](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L226)
|
|
33
|
+
|
|
34
|
+
#### Parameters
|
|
35
|
+
|
|
36
|
+
##### uwsApp
|
|
37
|
+
|
|
38
|
+
`TemplatedApp`
|
|
39
|
+
|
|
40
|
+
#### Returns
|
|
41
|
+
|
|
42
|
+
`HttpRouter`
|
|
43
|
+
|
|
44
|
+
## Properties
|
|
45
|
+
|
|
46
|
+
### listenPort
|
|
47
|
+
|
|
48
|
+
> **listenPort**: `number` = `0`
|
|
49
|
+
|
|
50
|
+
Defined in: [src/http/Router.ts:224](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L224)
|
|
51
|
+
|
|
52
|
+
The port the server is currently listening on (set after a successful `listen()` call).
|
|
53
|
+
|
|
54
|
+
## Accessors
|
|
55
|
+
|
|
56
|
+
### isListening
|
|
57
|
+
|
|
58
|
+
#### Get Signature
|
|
59
|
+
|
|
60
|
+
> **get** **isListening**(): `boolean`
|
|
61
|
+
|
|
62
|
+
Defined in: [src/http/Router.ts:231](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L231)
|
|
63
|
+
|
|
64
|
+
Returns `true` if the server is currently listening.
|
|
65
|
+
|
|
66
|
+
##### Returns
|
|
67
|
+
|
|
68
|
+
`boolean`
|
|
69
|
+
|
|
70
|
+
## Methods
|
|
71
|
+
|
|
72
|
+
### close()
|
|
73
|
+
|
|
74
|
+
> **close**(): `void`
|
|
75
|
+
|
|
76
|
+
Defined in: [src/http/Router.ts:471](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L471)
|
|
77
|
+
|
|
78
|
+
Closes the listen socket, stopping the server from accepting new connections.
|
|
79
|
+
|
|
80
|
+
#### Returns
|
|
81
|
+
|
|
82
|
+
`void`
|
|
83
|
+
|
|
84
|
+
***
|
|
85
|
+
|
|
86
|
+
### delete()
|
|
87
|
+
|
|
88
|
+
> **delete**(`routePath`, ...`handlers`): `this`
|
|
89
|
+
|
|
90
|
+
Defined in: [src/http/Router.ts:275](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L275)
|
|
91
|
+
|
|
92
|
+
#### Parameters
|
|
93
|
+
|
|
94
|
+
##### routePath
|
|
95
|
+
|
|
96
|
+
`string`
|
|
97
|
+
|
|
98
|
+
##### handlers
|
|
99
|
+
|
|
100
|
+
...[`RequestHandler`](../type-aliases/RequestHandler.md)[]
|
|
101
|
+
|
|
102
|
+
#### Returns
|
|
103
|
+
|
|
104
|
+
`this`
|
|
105
|
+
|
|
106
|
+
***
|
|
107
|
+
|
|
108
|
+
### get()
|
|
109
|
+
|
|
110
|
+
> **get**(`routePath`, ...`handlers`): `this`
|
|
111
|
+
|
|
112
|
+
Defined in: [src/http/Router.ts:257](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L257)
|
|
113
|
+
|
|
114
|
+
#### Parameters
|
|
115
|
+
|
|
116
|
+
##### routePath
|
|
117
|
+
|
|
118
|
+
`string`
|
|
119
|
+
|
|
120
|
+
##### handlers
|
|
121
|
+
|
|
122
|
+
...[`RequestHandler`](../type-aliases/RequestHandler.md)[]
|
|
123
|
+
|
|
124
|
+
#### Returns
|
|
125
|
+
|
|
126
|
+
`this`
|
|
127
|
+
|
|
128
|
+
***
|
|
129
|
+
|
|
130
|
+
### head()
|
|
131
|
+
|
|
132
|
+
> **head**(`routePath`, ...`handlers`): `this`
|
|
133
|
+
|
|
134
|
+
Defined in: [src/http/Router.ts:287](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L287)
|
|
135
|
+
|
|
136
|
+
#### Parameters
|
|
137
|
+
|
|
138
|
+
##### routePath
|
|
139
|
+
|
|
140
|
+
`string`
|
|
141
|
+
|
|
142
|
+
##### handlers
|
|
143
|
+
|
|
144
|
+
...[`RequestHandler`](../type-aliases/RequestHandler.md)[]
|
|
145
|
+
|
|
146
|
+
#### Returns
|
|
147
|
+
|
|
148
|
+
`this`
|
|
149
|
+
|
|
150
|
+
***
|
|
151
|
+
|
|
152
|
+
### listen()
|
|
153
|
+
|
|
154
|
+
> **listen**(`host`, `port`): `Promise`\<`void`\>
|
|
155
|
+
|
|
156
|
+
Defined in: [src/http/Router.ts:450](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L450)
|
|
157
|
+
|
|
158
|
+
Starts listening on the given host and port.
|
|
159
|
+
Resolves when the server is ready; rejects if the port cannot be bound.
|
|
160
|
+
|
|
161
|
+
#### Parameters
|
|
162
|
+
|
|
163
|
+
##### host
|
|
164
|
+
|
|
165
|
+
`string`
|
|
166
|
+
|
|
167
|
+
##### port
|
|
168
|
+
|
|
169
|
+
`number`
|
|
170
|
+
|
|
171
|
+
#### Returns
|
|
172
|
+
|
|
173
|
+
`Promise`\<`void`\>
|
|
174
|
+
|
|
175
|
+
***
|
|
176
|
+
|
|
177
|
+
### options()
|
|
178
|
+
|
|
179
|
+
> **options**(`routePath`, ...`handlers`): `this`
|
|
180
|
+
|
|
181
|
+
Defined in: [src/http/Router.ts:294](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L294)
|
|
182
|
+
|
|
183
|
+
#### Parameters
|
|
184
|
+
|
|
185
|
+
##### routePath
|
|
186
|
+
|
|
187
|
+
`string`
|
|
188
|
+
|
|
189
|
+
##### handlers
|
|
190
|
+
|
|
191
|
+
...[`RequestHandler`](../type-aliases/RequestHandler.md)[]
|
|
192
|
+
|
|
193
|
+
#### Returns
|
|
194
|
+
|
|
195
|
+
`this`
|
|
196
|
+
|
|
197
|
+
***
|
|
198
|
+
|
|
199
|
+
### patch()
|
|
200
|
+
|
|
201
|
+
> **patch**(`routePath`, ...`handlers`): `this`
|
|
202
|
+
|
|
203
|
+
Defined in: [src/http/Router.ts:281](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L281)
|
|
204
|
+
|
|
205
|
+
#### Parameters
|
|
206
|
+
|
|
207
|
+
##### routePath
|
|
208
|
+
|
|
209
|
+
`string`
|
|
210
|
+
|
|
211
|
+
##### handlers
|
|
212
|
+
|
|
213
|
+
...[`RequestHandler`](../type-aliases/RequestHandler.md)[]
|
|
214
|
+
|
|
215
|
+
#### Returns
|
|
216
|
+
|
|
217
|
+
`this`
|
|
218
|
+
|
|
219
|
+
***
|
|
220
|
+
|
|
221
|
+
### post()
|
|
222
|
+
|
|
223
|
+
> **post**(`routePath`, ...`handlers`): `this`
|
|
224
|
+
|
|
225
|
+
Defined in: [src/http/Router.ts:263](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L263)
|
|
226
|
+
|
|
227
|
+
#### Parameters
|
|
228
|
+
|
|
229
|
+
##### routePath
|
|
230
|
+
|
|
231
|
+
`string`
|
|
232
|
+
|
|
233
|
+
##### handlers
|
|
234
|
+
|
|
235
|
+
...[`RequestHandler`](../type-aliases/RequestHandler.md)[]
|
|
236
|
+
|
|
237
|
+
#### Returns
|
|
238
|
+
|
|
239
|
+
`this`
|
|
240
|
+
|
|
241
|
+
***
|
|
242
|
+
|
|
243
|
+
### put()
|
|
244
|
+
|
|
245
|
+
> **put**(`routePath`, ...`handlers`): `this`
|
|
246
|
+
|
|
247
|
+
Defined in: [src/http/Router.ts:269](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L269)
|
|
248
|
+
|
|
249
|
+
#### Parameters
|
|
250
|
+
|
|
251
|
+
##### routePath
|
|
252
|
+
|
|
253
|
+
`string`
|
|
254
|
+
|
|
255
|
+
##### handlers
|
|
256
|
+
|
|
257
|
+
...[`RequestHandler`](../type-aliases/RequestHandler.md)[]
|
|
258
|
+
|
|
259
|
+
#### Returns
|
|
260
|
+
|
|
261
|
+
`this`
|
|
262
|
+
|
|
263
|
+
***
|
|
264
|
+
|
|
265
|
+
### static()
|
|
266
|
+
|
|
267
|
+
> **static**(`basePath`): `this`
|
|
268
|
+
|
|
269
|
+
Defined in: [src/http/Router.ts:420](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L420)
|
|
270
|
+
|
|
271
|
+
Serves static files from a directory via a wildcard GET route.
|
|
272
|
+
Files not found on disk return 404.
|
|
273
|
+
|
|
274
|
+
#### Parameters
|
|
275
|
+
|
|
276
|
+
##### basePath
|
|
277
|
+
|
|
278
|
+
`string`
|
|
279
|
+
|
|
280
|
+
#### Returns
|
|
281
|
+
|
|
282
|
+
`this`
|
|
283
|
+
|
|
284
|
+
***
|
|
285
|
+
|
|
286
|
+
### use()
|
|
287
|
+
|
|
288
|
+
> **use**(...`handlers`): `this`
|
|
289
|
+
|
|
290
|
+
Defined in: [src/http/Router.ts:236](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L236)
|
|
291
|
+
|
|
292
|
+
Register global middleware that runs before every route handler.
|
|
293
|
+
|
|
294
|
+
#### Parameters
|
|
295
|
+
|
|
296
|
+
##### handlers
|
|
297
|
+
|
|
298
|
+
...[`RequestHandler`](../type-aliases/RequestHandler.md)[]
|
|
299
|
+
|
|
300
|
+
#### Returns
|
|
301
|
+
|
|
302
|
+
`this`
|
|
303
|
+
|
|
304
|
+
***
|
|
305
|
+
|
|
306
|
+
### ws()
|
|
307
|
+
|
|
308
|
+
> **ws**(`routePath`, `handlers`, `wsOptions?`, `upgradeAuth?`): `this`
|
|
309
|
+
|
|
310
|
+
Defined in: [src/http/Router.ts:312](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/http/Router.ts#L312)
|
|
311
|
+
|
|
312
|
+
Registers a WebSocket route. Handlers follow the same `(req, res, next)` pattern
|
|
313
|
+
as HTTP routes; they receive `req.websocket` containing the uWS WebSocket handle.
|
|
314
|
+
|
|
315
|
+
`upgradeAuth` is an optional pre-upgrade auth function. When provided it runs synchronously
|
|
316
|
+
inside the uWS `upgrade` callback before the handshake. If it returns `{ reject: true }`,
|
|
317
|
+
an HTTP 401 is sent and the upgrade is aborted. If it returns `{ user, ... }`, those
|
|
318
|
+
credentials are attached to the request so downstream middleware sees an authenticated user.
|
|
319
|
+
If it returns `{}`, auth falls through to the post-upgrade message-based LOGIN flow.
|
|
320
|
+
|
|
321
|
+
Both `path` and `path + "/"` are registered to avoid trailing-slash mismatch.
|
|
322
|
+
|
|
323
|
+
#### Parameters
|
|
324
|
+
|
|
325
|
+
##### routePath
|
|
326
|
+
|
|
327
|
+
`string`
|
|
328
|
+
|
|
329
|
+
##### handlers
|
|
330
|
+
|
|
331
|
+
[`RequestHandler`](../type-aliases/RequestHandler.md)[]
|
|
332
|
+
|
|
333
|
+
##### wsOptions?
|
|
334
|
+
|
|
335
|
+
`Partial`\<`WebSocketBehavior`\<`any`\>\>
|
|
336
|
+
|
|
337
|
+
##### upgradeAuth?
|
|
338
|
+
|
|
339
|
+
[`WsUpgradeAuth`](../type-aliases/WsUpgradeAuth.md)
|
|
340
|
+
|
|
341
|
+
#### Returns
|
|
342
|
+
|
|
343
|
+
`this`
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: JWTStrategy
|
|
8
8
|
|
|
9
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
9
|
+
Defined in: [src/auth/JWTStrategy.ts:63](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L63)
|
|
10
10
|
|
|
11
|
-
JWT authentication strategy. Performs JWT verification and searches for a token by one of the
|
|
12
|
-
following methods (in order of precedence):
|
|
13
|
-
* Query Parameter
|
|
14
|
-
* Authorization Header
|
|
11
|
+
JWT authentication strategy. Performs JWT verification and searches for a token by one of the
|
|
12
|
+
following methods (in order of precedence):
|
|
13
|
+
* Query Parameter
|
|
14
|
+
* Authorization Header
|
|
15
15
|
* Cookie
|
|
16
16
|
|
|
17
|
-
This class no longer extends `passport-strategy`; it is used directly by route middleware
|
|
17
|
+
This class no longer extends `passport-strategy`; it is used directly by route middleware
|
|
18
18
|
and returns a plain result object instead of calling Passport callbacks.
|
|
19
19
|
|
|
20
20
|
## Author
|
|
@@ -27,7 +27,7 @@ Jean-Philippe Steinmetz
|
|
|
27
27
|
|
|
28
28
|
> **new JWTStrategy**(`options?`): `JWTStrategy`
|
|
29
29
|
|
|
30
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
30
|
+
Defined in: [src/auth/JWTStrategy.ts:71](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L71)
|
|
31
31
|
|
|
32
32
|
#### Parameters
|
|
33
33
|
|
|
@@ -45,28 +45,51 @@ Defined in: [src/auth/JWTStrategy.ts:72](https://github.com/rapidrest/service-co
|
|
|
45
45
|
|
|
46
46
|
> `readonly` **name**: `string` = `"jwt"`
|
|
47
47
|
|
|
48
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
48
|
+
Defined in: [src/auth/JWTStrategy.ts:67](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L67)
|
|
49
49
|
|
|
50
50
|
## Methods
|
|
51
51
|
|
|
52
52
|
### authenticate()
|
|
53
53
|
|
|
54
|
-
> **authenticate**(`req`, `res`, `required?`): [`JWTAuthResult`](../interfaces/JWTAuthResult.md) \| `undefined
|
|
54
|
+
> **authenticate**(`req`, `res`, `required?`): `Promise`\<[`JWTAuthResult`](../interfaces/JWTAuthResult.md) \| `undefined`\>
|
|
55
55
|
|
|
56
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
56
|
+
Defined in: [src/auth/JWTStrategy.ts:134](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L134)
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
#### Parameters
|
|
59
|
+
|
|
60
|
+
##### req
|
|
61
|
+
|
|
62
|
+
[`HttpRequest`](../interfaces/HttpRequest.md)
|
|
63
|
+
|
|
64
|
+
##### res
|
|
65
|
+
|
|
66
|
+
[`HttpResponse`](../interfaces/HttpResponse.md)
|
|
67
|
+
|
|
68
|
+
##### required?
|
|
69
|
+
|
|
70
|
+
`boolean`
|
|
71
|
+
|
|
72
|
+
#### Returns
|
|
73
|
+
|
|
74
|
+
`Promise`\<[`JWTAuthResult`](../interfaces/JWTAuthResult.md) \| `undefined`\>
|
|
75
|
+
|
|
76
|
+
***
|
|
77
|
+
|
|
78
|
+
### authenticateSync()
|
|
79
|
+
|
|
80
|
+
> **authenticateSync**(`req`, `res`, `required?`): [`JWTAuthResult`](../interfaces/JWTAuthResult.md) \| `undefined`
|
|
81
|
+
|
|
82
|
+
Defined in: [src/auth/JWTStrategy.ts:169](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L169)
|
|
60
83
|
|
|
61
84
|
#### Parameters
|
|
62
85
|
|
|
63
86
|
##### req
|
|
64
87
|
|
|
65
|
-
`HttpRequest`
|
|
88
|
+
[`HttpRequest`](../interfaces/HttpRequest.md)
|
|
66
89
|
|
|
67
90
|
##### res
|
|
68
91
|
|
|
69
|
-
`HttpResponse`
|
|
92
|
+
[`HttpResponse`](../interfaces/HttpResponse.md)
|
|
70
93
|
|
|
71
94
|
##### required?
|
|
72
95
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: JWTStrategyOptions
|
|
8
8
|
|
|
9
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
9
|
+
Defined in: [src/auth/JWTStrategy.ts:19](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L19)
|
|
10
10
|
|
|
11
11
|
Describes the configuration options that can be used to initialize JWTStrategy.
|
|
12
12
|
|
|
@@ -30,10 +30,10 @@ Jean-Philippe Steinmetz
|
|
|
30
30
|
|
|
31
31
|
> **allowQueryParam**: `boolean` = `false`
|
|
32
32
|
|
|
33
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
33
|
+
Defined in: [src/auth/JWTStrategy.ts:37](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L37)
|
|
34
34
|
|
|
35
|
-
Set to `true` to allow tokens to be supplied via the `queryKey` URL parameter.
|
|
36
|
-
Disabled by default — query parameters appear in server logs, browser history, and
|
|
35
|
+
Set to `true` to allow tokens to be supplied via the `queryKey` URL parameter.
|
|
36
|
+
Disabled by default — query parameters appear in server logs, browser history, and
|
|
37
37
|
Referer headers, which permanently exposes tokens outside the application.
|
|
38
38
|
|
|
39
39
|
***
|
|
@@ -42,7 +42,7 @@ Referer headers, which permanently exposes tokens outside the application.
|
|
|
42
42
|
|
|
43
43
|
> `optional` **config?**: `JWTUtilsConfig`
|
|
44
44
|
|
|
45
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
45
|
+
Defined in: [src/auth/JWTStrategy.ts:21](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L21)
|
|
46
46
|
|
|
47
47
|
The configuration options to pass to the JWTUtils library during token verification.
|
|
48
48
|
|
|
@@ -52,7 +52,7 @@ The configuration options to pass to the JWTUtils library during token verificat
|
|
|
52
52
|
|
|
53
53
|
> **cookieName**: `string` = `"jwt"`
|
|
54
54
|
|
|
55
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
55
|
+
Defined in: [src/auth/JWTStrategy.ts:27](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L27)
|
|
56
56
|
|
|
57
57
|
The name of the cookie to retrieve the token from when using cookie based authentication. Default value is `jwt`.
|
|
58
58
|
|
|
@@ -62,7 +62,7 @@ The name of the cookie to retrieve the token from when using cookie based authen
|
|
|
62
62
|
|
|
63
63
|
> **cookieSecure**: `boolean` = `false`
|
|
64
64
|
|
|
65
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
65
|
+
Defined in: [src/auth/JWTStrategy.ts:29](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L29)
|
|
66
66
|
|
|
67
67
|
The name of the secured cookie to retreive the token from when using cookie based authentication.
|
|
68
68
|
|
|
@@ -72,7 +72,7 @@ The name of the secured cookie to retreive the token from when using cookie base
|
|
|
72
72
|
|
|
73
73
|
> **headerKey**: `string` = `"authorization"`
|
|
74
74
|
|
|
75
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
75
|
+
Defined in: [src/auth/JWTStrategy.ts:23](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L23)
|
|
76
76
|
|
|
77
77
|
The name of the header to look for when performing header based authentication. Default value is `Authorization`.
|
|
78
78
|
|
|
@@ -82,7 +82,7 @@ The name of the header to look for when performing header based authentication.
|
|
|
82
82
|
|
|
83
83
|
> **headerScheme**: `string` = "(jwt\|bearer)"
|
|
84
84
|
|
|
85
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
85
|
+
Defined in: [src/auth/JWTStrategy.ts:25](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L25)
|
|
86
86
|
|
|
87
87
|
The authorization scheme type when using header based authentication. Default value is `jwt`.
|
|
88
88
|
|
|
@@ -92,6 +92,6 @@ The authorization scheme type when using header based authentication. Default va
|
|
|
92
92
|
|
|
93
93
|
> **queryKey**: `string` = `"auth_token"`
|
|
94
94
|
|
|
95
|
-
Defined in: [src/auth/JWTStrategy.ts:
|
|
95
|
+
Defined in: [src/auth/JWTStrategy.ts:31](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/auth/JWTStrategy.ts#L31)
|
|
96
96
|
|
|
97
97
|
The name of the request query parameter to retrieve the token from when using query based authentication. Default value is `auth_token`.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: MetricsRoute
|
|
8
8
|
|
|
9
|
-
Defined in: [src/routes/MetricsRoute.ts:19](https://github.com/rapidrest/service-core/blob/
|
|
9
|
+
Defined in: [src/routes/MetricsRoute.ts:19](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/routes/MetricsRoute.ts#L19)
|
|
10
10
|
|
|
11
11
|
Handles all REST API requests for the endpoint `/metrics'. This route handler produces Prometheus compatible metrics
|
|
12
12
|
for use with a Prometheus based server.
|
|
@@ -20,7 +20,7 @@ from the provided `prom-client` dependency. See the `prom-client` documentation
|
|
|
20
20
|
|
|
21
21
|
> **new MetricsRoute**(): `MetricsRoute`
|
|
22
22
|
|
|
23
|
-
Defined in: [src/routes/MetricsRoute.ts:30](https://github.com/rapidrest/service-core/blob/
|
|
23
|
+
Defined in: [src/routes/MetricsRoute.ts:30](https://github.com/rapidrest/service-core/blob/5cd5bc79b3569101eabf54dec613fd4745a69b2b/src/routes/MetricsRoute.ts#L30)
|
|
24
24
|
|
|
25
25
|
#### Returns
|
|
26
26
|
|