@forklaunch/express 0.4.6 → 0.4.8
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/lib/index.d.mts +1728 -5
- package/lib/index.d.ts +1728 -5
- package/lib/index.js +3 -1
- package/lib/index.mjs +3 -1
- package/package.json +7 -7
package/lib/index.d.mts
CHANGED
@@ -10,22 +10,46 @@ import * as express_serve_static_core from 'express-serve-static-core';
|
|
10
10
|
|
11
11
|
/**
|
12
12
|
* Application class that sets up an Express server with Forklaunch routers and middleware.
|
13
|
+
* This class extends ForklaunchExpressLikeApplication to provide Express-specific functionality.
|
13
14
|
*
|
14
|
-
* @template SV - A type that extends AnySchemaValidator.
|
15
|
+
* @template SV - A type that extends AnySchemaValidator for schema validation.
|
16
|
+
* @example
|
17
|
+
* ```typescript
|
18
|
+
* const app = new Application(schemaValidator, openTelemetryCollector);
|
19
|
+
* app.listen(3000, () => console.log('Server running on port 3000'));
|
20
|
+
* ```
|
15
21
|
*/
|
16
22
|
declare class Application<SV extends AnySchemaValidator> extends ForklaunchExpressLikeApplication<SV, Express, RequestHandler, Request, Response, NextFunction> {
|
17
23
|
private readonly docsConfiguration?;
|
18
24
|
/**
|
19
25
|
* Creates an instance of Application.
|
20
26
|
*
|
21
|
-
* @param {SV} schemaValidator - The schema validator.
|
27
|
+
* @param {SV} schemaValidator - The schema validator for request/response validation.
|
28
|
+
* @param {OpenTelemetryCollector<MetricsDefinition>} openTelemetryCollector - Collector for OpenTelemetry metrics.
|
29
|
+
* @param {DocsConfiguration} [docsConfiguration] - Optional configuration for API documentation (Swagger/Scalar).
|
22
30
|
*/
|
23
31
|
constructor(schemaValidator: SV, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, docsConfiguration?: DocsConfiguration | undefined);
|
24
32
|
/**
|
25
|
-
* Starts the server and sets up
|
33
|
+
* Starts the Express server and sets up API documentation (Swagger/Scalar).
|
34
|
+
* This method is overloaded to support various ways of starting the server.
|
35
|
+
*
|
36
|
+
* @param {number} [port] - The port number to listen on. Defaults to process.env.PORT.
|
37
|
+
* @param {string} [hostname] - The hostname to bind to.
|
38
|
+
* @param {number} [backlog] - The maximum length of the queue of pending connections.
|
39
|
+
* @param {() => void} [callback] - Optional callback to execute when the server starts listening.
|
40
|
+
* @returns {Server} - The HTTP server instance.
|
26
41
|
*
|
27
|
-
* @
|
28
|
-
*
|
42
|
+
* @example
|
43
|
+
* ```typescript
|
44
|
+
* // Start server on port 3000
|
45
|
+
* app.listen(3000);
|
46
|
+
*
|
47
|
+
* // Start server with callback
|
48
|
+
* app.listen(3000, () => console.log('Server started'));
|
49
|
+
*
|
50
|
+
* // Start server with hostname and port
|
51
|
+
* app.listen(3000, 'localhost');
|
52
|
+
* ```
|
29
53
|
*/
|
30
54
|
listen(port: number, hostname: string, backlog: number, callback?: () => void): Server;
|
31
55
|
listen(port: number, hostname: string, callback?: () => void): Server;
|
@@ -78,6 +102,33 @@ declare class Router<SV extends AnySchemaValidator, BasePath extends `/${string}
|
|
78
102
|
unlink: TypedMiddlewareDefinition<this, SV, Request, Response, NextFunction>;
|
79
103
|
}
|
80
104
|
|
105
|
+
/**
|
106
|
+
* Creates a checkout route handler with schema validation and type safety.
|
107
|
+
*
|
108
|
+
* @template SV - The schema validator type
|
109
|
+
* @template Path - The path type
|
110
|
+
* @template P - The path parameters type
|
111
|
+
* @template ResBodyMap - The response body map type
|
112
|
+
* @template ReqBody - The request body type
|
113
|
+
* @template ReqQuery - The request query type
|
114
|
+
* @template ReqHeaders - The request headers type
|
115
|
+
* @template ResHeaders - The response headers type
|
116
|
+
* @template LocalsObj - The locals object type
|
117
|
+
*
|
118
|
+
* @param {SV} schemaValidator - The schema validator instance
|
119
|
+
* @param {Path} path - The path of the route
|
120
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
121
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The handlers for the route
|
122
|
+
*
|
123
|
+
* @example
|
124
|
+
* ```typescript
|
125
|
+
* const checkout = checkout(
|
126
|
+
* schemaValidator,
|
127
|
+
* '/checkout',
|
128
|
+
* contractDetails,
|
129
|
+
* handler);
|
130
|
+
* ```
|
131
|
+
*/
|
81
132
|
declare const checkout: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
82
133
|
_typedHandler: true;
|
83
134
|
_path: Path;
|
@@ -85,6 +136,81 @@ declare const checkout: <SV extends AnySchemaValidator, Path extends `/${string}
|
|
85
136
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
86
137
|
};
|
87
138
|
|
139
|
+
/**
|
140
|
+
* Creates a COPY route handler with schema validation and type safety.
|
141
|
+
*
|
142
|
+
* @template SV - The schema validator type
|
143
|
+
* @template Path - The route path type (must start with '/')
|
144
|
+
* @template P - The path parameters type
|
145
|
+
* @template ResBodyMap - The response body map type
|
146
|
+
* @template ReqBody - The request body type
|
147
|
+
* @template ReqQuery - The request query parameters type
|
148
|
+
* @template ReqHeaders - The request headers type
|
149
|
+
* @template ResHeaders - The response headers type
|
150
|
+
* @template LocalsObj - The locals object type
|
151
|
+
*
|
152
|
+
* @param {SV} schemaValidator - The schema validator instance
|
153
|
+
* @param {Path} path - The route path
|
154
|
+
* @param {ContractDetails<SV, 'copy', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
155
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
156
|
+
*
|
157
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
158
|
+
*
|
159
|
+
* @example
|
160
|
+
* ```typescript
|
161
|
+
* copy(
|
162
|
+
* schemaValidator,
|
163
|
+
* '/files/:id',
|
164
|
+
* {
|
165
|
+
* summary: 'Copy file',
|
166
|
+
* description: 'Creates a copy of a file at a new location',
|
167
|
+
* tags: ['files'],
|
168
|
+
* parameters: [
|
169
|
+
* {
|
170
|
+
* name: 'id',
|
171
|
+
* in: 'path',
|
172
|
+
* required: true,
|
173
|
+
* schema: { type: 'string' }
|
174
|
+
* }
|
175
|
+
* ],
|
176
|
+
* requestBody: {
|
177
|
+
* content: {
|
178
|
+
* 'application/json': {
|
179
|
+
* schema: {
|
180
|
+
* type: 'object',
|
181
|
+
* properties: {
|
182
|
+
* destination: { type: 'string' }
|
183
|
+
* }
|
184
|
+
* }
|
185
|
+
* }
|
186
|
+
* }
|
187
|
+
* },
|
188
|
+
* responses: {
|
189
|
+
* 201: {
|
190
|
+
* description: 'File copied successfully',
|
191
|
+
* content: {
|
192
|
+
* 'application/json': {
|
193
|
+
* schema: {
|
194
|
+
* type: 'object',
|
195
|
+
* properties: {
|
196
|
+
* id: { type: 'string' },
|
197
|
+
* location: { type: 'string' }
|
198
|
+
* }
|
199
|
+
* }
|
200
|
+
* }
|
201
|
+
* }
|
202
|
+
* }
|
203
|
+
* }
|
204
|
+
* },
|
205
|
+
* async (req, res) => {
|
206
|
+
* const { id } = req.params;
|
207
|
+
* const { destination } = req.body;
|
208
|
+
* const result = await copyFile(id, destination);
|
209
|
+
* res.status(201).json(result);
|
210
|
+
* }
|
211
|
+
* );
|
212
|
+
* ```
|
213
|
+
*/
|
88
214
|
declare const copy: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
89
215
|
_typedHandler: true;
|
90
216
|
_path: Path;
|
@@ -92,12 +218,236 @@ declare const copy: <SV extends AnySchemaValidator, Path extends `/${string}`, P
|
|
92
218
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
93
219
|
};
|
94
220
|
|
221
|
+
/**
|
222
|
+
* Creates a DELETE route handler with schema validation and type safety.
|
223
|
+
*
|
224
|
+
* @template SV - The schema validator type
|
225
|
+
* @template Path - The route path type (must start with '/')
|
226
|
+
* @template P - The path parameters type
|
227
|
+
* @template ResBodyMap - The response body map type
|
228
|
+
* @template ReqQuery - The request query parameters type
|
229
|
+
* @template ReqHeaders - The request headers type
|
230
|
+
* @template ResHeaders - The response headers type
|
231
|
+
* @template LocalsObj - The locals object type
|
232
|
+
*
|
233
|
+
* @param {SV} schemaValidator - The schema validator instance
|
234
|
+
* @param {Path} path - The route path
|
235
|
+
* @param {ContractDetails<SV, 'delete', Path, P, ResBodyMap, never, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
236
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, never, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
237
|
+
*
|
238
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
239
|
+
*
|
240
|
+
* @example
|
241
|
+
* ```typescript
|
242
|
+
* del(
|
243
|
+
* schemaValidator,
|
244
|
+
* '/users/:id',
|
245
|
+
* {
|
246
|
+
* summary: 'Delete user',
|
247
|
+
* description: 'Deletes a user by ID',
|
248
|
+
* tags: ['users'],
|
249
|
+
* parameters: [
|
250
|
+
* {
|
251
|
+
* name: 'id',
|
252
|
+
* in: 'path',
|
253
|
+
* required: true,
|
254
|
+
* schema: { type: 'string' }
|
255
|
+
* }
|
256
|
+
* ],
|
257
|
+
* responses: {
|
258
|
+
* 204: {
|
259
|
+
* description: 'User deleted successfully'
|
260
|
+
* }
|
261
|
+
* }
|
262
|
+
* },
|
263
|
+
* async (req, res) => {
|
264
|
+
* const { id } = req.params;
|
265
|
+
* await deleteUser(id);
|
266
|
+
* res.status(204).send();
|
267
|
+
* }
|
268
|
+
* );
|
269
|
+
* ```
|
270
|
+
*/
|
95
271
|
declare const delete_: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "delete", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "delete", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>;
|
96
272
|
|
273
|
+
/**
|
274
|
+
* Creates a GET route handler with schema validation and type safety.
|
275
|
+
*
|
276
|
+
* @template SV - Schema validator type extending AnySchemaValidator
|
277
|
+
* @template Path - Route path type extending string with leading slash
|
278
|
+
* @template P - Parameters object type extending ParamsObject
|
279
|
+
* @template ResBodyMap - Response body map type extending ResponsesObject
|
280
|
+
* @template ReqBody - Request body type extending Body
|
281
|
+
* @template ReqQuery - Request query type extending QueryObject
|
282
|
+
* @template ReqHeaders - Request headers type extending HeadersObject
|
283
|
+
* @template ResHeaders - Response headers type extending HeadersObject
|
284
|
+
* @template LocalsObj - Local variables type extending Record<string, unknown>
|
285
|
+
*
|
286
|
+
* @param {SV} schemaValidator - Schema validator instance
|
287
|
+
* @param {Path} path - Route path starting with '/'
|
288
|
+
* @param {ContractDetails} contractDetails - Contract details for route validation
|
289
|
+
* @param {...ExpressLikeSchemaHandler[]} handlers - Route handler middleware functions
|
290
|
+
* @returns {Function} Express route handler with schema validation
|
291
|
+
*
|
292
|
+
* @example
|
293
|
+
* ```typescript
|
294
|
+
* const getUser = get(
|
295
|
+
* schemaValidator,
|
296
|
+
* '/users/:id',
|
297
|
+
* {
|
298
|
+
* params: { id: 'string' },
|
299
|
+
* responses: {
|
300
|
+
* 200: { type: 'object', properties: { name: { type: 'string' } } }
|
301
|
+
* }
|
302
|
+
* },
|
303
|
+
* async (req, res) => {
|
304
|
+
* const user = await getUserById(req.params.id);
|
305
|
+
* res.json(user);
|
306
|
+
* }
|
307
|
+
* );
|
308
|
+
* ```
|
309
|
+
*/
|
97
310
|
declare const get: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "get", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "get", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>;
|
98
311
|
|
312
|
+
/**
|
313
|
+
* Creates a HEAD route handler with schema validation and type safety.
|
314
|
+
*
|
315
|
+
* @template SV - The schema validator type
|
316
|
+
* @template Path - The route path type (must start with '/')
|
317
|
+
* @template P - The path parameters type
|
318
|
+
* @template ResBodyMap - The response body map type
|
319
|
+
* @template ReqQuery - The request query parameters type
|
320
|
+
* @template ReqHeaders - The request headers type
|
321
|
+
* @template ResHeaders - The response headers type
|
322
|
+
* @template LocalsObj - The locals object type
|
323
|
+
*
|
324
|
+
* @param {SV} schemaValidator - The schema validator instance
|
325
|
+
* @param {Path} path - The route path
|
326
|
+
* @param {ContractDetails<SV, 'head', Path, P, ResBodyMap, never, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
327
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, never, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
328
|
+
*
|
329
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
330
|
+
*
|
331
|
+
* @example
|
332
|
+
* ```typescript
|
333
|
+
* head(
|
334
|
+
* schemaValidator,
|
335
|
+
* '/files/:id',
|
336
|
+
* {
|
337
|
+
* summary: 'Get file metadata',
|
338
|
+
* description: 'Returns metadata about a file without the file content',
|
339
|
+
* tags: ['files'],
|
340
|
+
* parameters: [
|
341
|
+
* {
|
342
|
+
* name: 'id',
|
343
|
+
* in: 'path',
|
344
|
+
* required: true,
|
345
|
+
* schema: { type: 'string' }
|
346
|
+
* }
|
347
|
+
* ],
|
348
|
+
* responses: {
|
349
|
+
* 200: {
|
350
|
+
* description: 'File metadata',
|
351
|
+
* headers: {
|
352
|
+
* 'Content-Length': {
|
353
|
+
* schema: { type: 'integer' }
|
354
|
+
* },
|
355
|
+
* 'Content-Type': {
|
356
|
+
* schema: { type: 'string' }
|
357
|
+
* }
|
358
|
+
* }
|
359
|
+
* }
|
360
|
+
* }
|
361
|
+
* },
|
362
|
+
* async (req, res) => {
|
363
|
+
* const { id } = req.params;
|
364
|
+
* const metadata = await getFileMetadata(id);
|
365
|
+
* res.set('Content-Length', metadata.size);
|
366
|
+
* res.set('Content-Type', metadata.type);
|
367
|
+
* res.status(200).end();
|
368
|
+
* }
|
369
|
+
* );
|
370
|
+
* ```
|
371
|
+
*/
|
99
372
|
declare const head: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "head", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "head", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>;
|
100
373
|
|
374
|
+
/**
|
375
|
+
* Creates a LINK route handler with schema validation and type safety.
|
376
|
+
*
|
377
|
+
* @template SV - The schema validator type
|
378
|
+
* @template Path - The route path type (must start with '/')
|
379
|
+
* @template P - The path parameters type
|
380
|
+
* @template ResBodyMap - The response body map type
|
381
|
+
* @template ReqBody - The request body type
|
382
|
+
* @template ReqQuery - The request query parameters type
|
383
|
+
* @template ReqHeaders - The request headers type
|
384
|
+
* @template ResHeaders - The response headers type
|
385
|
+
* @template LocalsObj - The locals object type
|
386
|
+
*
|
387
|
+
* @param {SV} schemaValidator - The schema validator instance
|
388
|
+
* @param {Path} path - The route path
|
389
|
+
* @param {ContractDetails<SV, 'link', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
390
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
391
|
+
*
|
392
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
393
|
+
*
|
394
|
+
* @example
|
395
|
+
* ```typescript
|
396
|
+
* link(
|
397
|
+
* schemaValidator,
|
398
|
+
* '/resources/:id',
|
399
|
+
* {
|
400
|
+
* summary: 'Link resources',
|
401
|
+
* description: 'Establishes a relationship between two resources',
|
402
|
+
* tags: ['resources'],
|
403
|
+
* parameters: [
|
404
|
+
* {
|
405
|
+
* name: 'id',
|
406
|
+
* in: 'path',
|
407
|
+
* required: true,
|
408
|
+
* schema: { type: 'string' }
|
409
|
+
* }
|
410
|
+
* ],
|
411
|
+
* requestBody: {
|
412
|
+
* content: {
|
413
|
+
* 'application/json': {
|
414
|
+
* schema: {
|
415
|
+
* type: 'object',
|
416
|
+
* properties: {
|
417
|
+
* targetId: { type: 'string' },
|
418
|
+
* relationshipType: { type: 'string' }
|
419
|
+
* }
|
420
|
+
* }
|
421
|
+
* }
|
422
|
+
* }
|
423
|
+
* },
|
424
|
+
* responses: {
|
425
|
+
* 201: {
|
426
|
+
* description: 'Resources linked successfully',
|
427
|
+
* content: {
|
428
|
+
* 'application/json': {
|
429
|
+
* schema: {
|
430
|
+
* type: 'object',
|
431
|
+
* properties: {
|
432
|
+
* sourceId: { type: 'string' },
|
433
|
+
* targetId: { type: 'string' },
|
434
|
+
* relationshipType: { type: 'string' }
|
435
|
+
* }
|
436
|
+
* }
|
437
|
+
* }
|
438
|
+
* }
|
439
|
+
* }
|
440
|
+
* }
|
441
|
+
* },
|
442
|
+
* async (req, res) => {
|
443
|
+
* const { id } = req.params;
|
444
|
+
* const { targetId, relationshipType } = req.body;
|
445
|
+
* const result = await linkResources(id, targetId, relationshipType);
|
446
|
+
* res.status(201).json(result);
|
447
|
+
* }
|
448
|
+
* );
|
449
|
+
* ```
|
450
|
+
*/
|
101
451
|
declare const link: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
102
452
|
_typedHandler: true;
|
103
453
|
_path: Path;
|
@@ -105,6 +455,82 @@ declare const link: <SV extends AnySchemaValidator, Path extends `/${string}`, P
|
|
105
455
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
106
456
|
};
|
107
457
|
|
458
|
+
/**
|
459
|
+
* Creates a LOCK route handler with schema validation and type safety.
|
460
|
+
*
|
461
|
+
* @template SV - The schema validator type
|
462
|
+
* @template Path - The route path type (must start with '/')
|
463
|
+
* @template P - The path parameters type
|
464
|
+
* @template ResBodyMap - The response body map type
|
465
|
+
* @template ReqBody - The request body type
|
466
|
+
* @template ReqQuery - The request query parameters type
|
467
|
+
* @template ReqHeaders - The request headers type
|
468
|
+
* @template ResHeaders - The response headers type
|
469
|
+
* @template LocalsObj - The locals object type
|
470
|
+
*
|
471
|
+
* @param {SV} schemaValidator - The schema validator instance
|
472
|
+
* @param {Path} path - The route path
|
473
|
+
* @param {ContractDetails<SV, 'lock', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
474
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
475
|
+
*
|
476
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
477
|
+
*
|
478
|
+
* @example
|
479
|
+
* ```typescript
|
480
|
+
* lock(
|
481
|
+
* schemaValidator,
|
482
|
+
* '/resources/:id',
|
483
|
+
* {
|
484
|
+
* summary: 'Lock resource',
|
485
|
+
* description: 'Locks a resource to prevent concurrent modifications',
|
486
|
+
* tags: ['resources'],
|
487
|
+
* parameters: [
|
488
|
+
* {
|
489
|
+
* name: 'id',
|
490
|
+
* in: 'path',
|
491
|
+
* required: true,
|
492
|
+
* schema: { type: 'string' }
|
493
|
+
* }
|
494
|
+
* ],
|
495
|
+
* requestBody: {
|
496
|
+
* content: {
|
497
|
+
* 'application/json': {
|
498
|
+
* schema: {
|
499
|
+
* type: 'object',
|
500
|
+
* properties: {
|
501
|
+
* timeout: { type: 'integer' },
|
502
|
+
* owner: { type: 'string' }
|
503
|
+
* }
|
504
|
+
* }
|
505
|
+
* }
|
506
|
+
* }
|
507
|
+
* },
|
508
|
+
* responses: {
|
509
|
+
* 200: {
|
510
|
+
* description: 'Resource locked successfully',
|
511
|
+
* content: {
|
512
|
+
* 'application/json': {
|
513
|
+
* schema: {
|
514
|
+
* type: 'object',
|
515
|
+
* properties: {
|
516
|
+
* lockToken: { type: 'string' },
|
517
|
+
* expiresAt: { type: 'string', format: 'date-time' }
|
518
|
+
* }
|
519
|
+
* }
|
520
|
+
* }
|
521
|
+
* }
|
522
|
+
* }
|
523
|
+
* }
|
524
|
+
* },
|
525
|
+
* async (req, res) => {
|
526
|
+
* const { id } = req.params;
|
527
|
+
* const { timeout, owner } = req.body;
|
528
|
+
* const result = await lockResource(id, timeout, owner);
|
529
|
+
* res.json(result);
|
530
|
+
* }
|
531
|
+
* );
|
532
|
+
* ```
|
533
|
+
*/
|
108
534
|
declare const lock: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
109
535
|
_typedHandler: true;
|
110
536
|
_path: Path;
|
@@ -112,6 +538,77 @@ declare const lock: <SV extends AnySchemaValidator, Path extends `/${string}`, P
|
|
112
538
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
113
539
|
};
|
114
540
|
|
541
|
+
/**
|
542
|
+
* Creates a M-SEARCH route handler with schema validation and type safety.
|
543
|
+
*
|
544
|
+
* @template SV - The schema validator type
|
545
|
+
* @template Path - The route path type (must start with '/')
|
546
|
+
* @template P - The path parameters type
|
547
|
+
* @template ResBodyMap - The response body map type
|
548
|
+
* @template ReqBody - The request body type
|
549
|
+
* @template ReqQuery - The request query parameters type
|
550
|
+
* @template ReqHeaders - The request headers type
|
551
|
+
* @template ResHeaders - The response headers type
|
552
|
+
* @template LocalsObj - The locals object type
|
553
|
+
*
|
554
|
+
* @param {SV} schemaValidator - The schema validator instance
|
555
|
+
* @param {Path} path - The route path
|
556
|
+
* @param {ContractDetails<SV, 'm-search', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
557
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
558
|
+
*
|
559
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
560
|
+
*
|
561
|
+
* @example
|
562
|
+
* ```typescript
|
563
|
+
* mSearch(
|
564
|
+
* schemaValidator,
|
565
|
+
* '/devices',
|
566
|
+
* {
|
567
|
+
* summary: 'Search for devices',
|
568
|
+
* description: 'Multicast search for devices on the network',
|
569
|
+
* tags: ['devices'],
|
570
|
+
* requestBody: {
|
571
|
+
* content: {
|
572
|
+
* 'application/json': {
|
573
|
+
* schema: {
|
574
|
+
* type: 'object',
|
575
|
+
* properties: {
|
576
|
+
* searchType: { type: 'string' },
|
577
|
+
* maxWait: { type: 'integer' }
|
578
|
+
* }
|
579
|
+
* }
|
580
|
+
* }
|
581
|
+
* }
|
582
|
+
* },
|
583
|
+
* responses: {
|
584
|
+
* 200: {
|
585
|
+
* description: 'Devices found',
|
586
|
+
* content: {
|
587
|
+
* 'application/json': {
|
588
|
+
* schema: {
|
589
|
+
* type: 'array',
|
590
|
+
* items: {
|
591
|
+
* type: 'object',
|
592
|
+
* properties: {
|
593
|
+
* id: { type: 'string' },
|
594
|
+
* type: { type: 'string' },
|
595
|
+
* location: { type: 'string' }
|
596
|
+
* }
|
597
|
+
* }
|
598
|
+
* }
|
599
|
+
* }
|
600
|
+
* }
|
601
|
+
* }
|
602
|
+
* }
|
603
|
+
* },
|
604
|
+
* async (req, res) => {
|
605
|
+
* const { searchType, maxWait } = req.body;
|
606
|
+
* const devices = await searchDevices(searchType, maxWait);
|
607
|
+
* res.json(devices);
|
608
|
+
* }
|
609
|
+
* );
|
610
|
+
* ```
|
611
|
+
*/
|
115
612
|
declare const mSearch: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
116
613
|
_typedHandler: true;
|
117
614
|
_path: Path;
|
@@ -119,6 +616,93 @@ declare const mSearch: <SV extends AnySchemaValidator, Path extends `/${string}`
|
|
119
616
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
120
617
|
};
|
121
618
|
|
619
|
+
/**
|
620
|
+
* Creates a MERGE route handler with schema validation and type safety.
|
621
|
+
*
|
622
|
+
* @template SV - The schema validator type
|
623
|
+
* @template Path - The route path type (must start with '/')
|
624
|
+
* @template P - The path parameters type
|
625
|
+
* @template ResBodyMap - The response body map type
|
626
|
+
* @template ReqBody - The request body type
|
627
|
+
* @template ReqQuery - The request query parameters type
|
628
|
+
* @template ReqHeaders - The request headers type
|
629
|
+
* @template ResHeaders - The response headers type
|
630
|
+
* @template LocalsObj - The locals object type
|
631
|
+
*
|
632
|
+
* @param {SV} schemaValidator - The schema validator instance
|
633
|
+
* @param {Path} path - The route path
|
634
|
+
* @param {ContractDetails<SV, 'merge', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
635
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
636
|
+
*
|
637
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
638
|
+
*
|
639
|
+
* @example
|
640
|
+
* ```typescript
|
641
|
+
* merge(
|
642
|
+
* schemaValidator,
|
643
|
+
* '/documents/:id',
|
644
|
+
* {
|
645
|
+
* summary: 'Merge document',
|
646
|
+
* description: 'Merges changes from multiple sources into a document',
|
647
|
+
* tags: ['documents'],
|
648
|
+
* parameters: [
|
649
|
+
* {
|
650
|
+
* name: 'id',
|
651
|
+
* in: 'path',
|
652
|
+
* required: true,
|
653
|
+
* schema: { type: 'string' }
|
654
|
+
* }
|
655
|
+
* ],
|
656
|
+
* requestBody: {
|
657
|
+
* content: {
|
658
|
+
* 'application/json': {
|
659
|
+
* schema: {
|
660
|
+
* type: 'object',
|
661
|
+
* properties: {
|
662
|
+
* changes: {
|
663
|
+
* type: 'array',
|
664
|
+
* items: {
|
665
|
+
* type: 'object',
|
666
|
+
* properties: {
|
667
|
+
* source: { type: 'string' },
|
668
|
+
* content: { type: 'string' }
|
669
|
+
* }
|
670
|
+
* }
|
671
|
+
* }
|
672
|
+
* }
|
673
|
+
* }
|
674
|
+
* }
|
675
|
+
* }
|
676
|
+
* },
|
677
|
+
* responses: {
|
678
|
+
* 200: {
|
679
|
+
* description: 'Document merged successfully',
|
680
|
+
* content: {
|
681
|
+
* 'application/json': {
|
682
|
+
* schema: {
|
683
|
+
* type: 'object',
|
684
|
+
* properties: {
|
685
|
+
* id: { type: 'string' },
|
686
|
+
* mergedContent: { type: 'string' },
|
687
|
+
* conflicts: {
|
688
|
+
* type: 'array',
|
689
|
+
* items: { type: 'string' }
|
690
|
+
* }
|
691
|
+
* }
|
692
|
+
* }
|
693
|
+
* }
|
694
|
+
* }
|
695
|
+
* }
|
696
|
+
* }
|
697
|
+
* },
|
698
|
+
* async (req, res) => {
|
699
|
+
* const { id } = req.params;
|
700
|
+
* const { changes } = req.body;
|
701
|
+
* const result = await mergeDocument(id, changes);
|
702
|
+
* res.json(result);
|
703
|
+
* }
|
704
|
+
* );
|
705
|
+
*/
|
122
706
|
declare const merge: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
123
707
|
_typedHandler: true;
|
124
708
|
_path: Path;
|
@@ -126,6 +710,58 @@ declare const merge: <SV extends AnySchemaValidator, Path extends `/${string}`,
|
|
126
710
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
127
711
|
};
|
128
712
|
|
713
|
+
/**
|
714
|
+
* Creates a middleware route handler with schema validation and type safety.
|
715
|
+
*
|
716
|
+
* @template SV - The schema validator type
|
717
|
+
* @template Path - The route path type (must start with '/')
|
718
|
+
* @template P - The path parameters type
|
719
|
+
* @template ResBodyMap - The response body map type
|
720
|
+
* @template ReqBody - The request body type
|
721
|
+
* @template ReqQuery - The request query parameters type
|
722
|
+
* @template ReqHeaders - The request headers type
|
723
|
+
* @template ResHeaders - The response headers type
|
724
|
+
* @template LocalsObj - The locals object type
|
725
|
+
*
|
726
|
+
* @param {SV} schemaValidator - The schema validator instance
|
727
|
+
* @param {Path} path - The route path
|
728
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
729
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
730
|
+
*
|
731
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
732
|
+
*
|
733
|
+
* @example
|
734
|
+
* ```typescript
|
735
|
+
* middleware(
|
736
|
+
* schemaValidator,
|
737
|
+
* '/middleware',
|
738
|
+
* {
|
739
|
+
* summary: 'Middleware example',
|
740
|
+
* description: 'Example middleware route',
|
741
|
+
* tags: ['middleware'],
|
742
|
+
* responses: {
|
743
|
+
* 200: {
|
744
|
+
* description: 'Middleware executed successfully',
|
745
|
+
* content: {
|
746
|
+
* 'application/json': {
|
747
|
+
* schema: {
|
748
|
+
* type: 'object',
|
749
|
+
* properties: {
|
750
|
+
* message: { type: 'string' }
|
751
|
+
* }
|
752
|
+
* }
|
753
|
+
* }
|
754
|
+
* }
|
755
|
+
* }
|
756
|
+
* }
|
757
|
+
* },
|
758
|
+
* async (req, res, next) => {
|
759
|
+
* // Middleware logic
|
760
|
+
* next();
|
761
|
+
* }
|
762
|
+
* );
|
763
|
+
* ```
|
764
|
+
*/
|
129
765
|
declare const middleware: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
130
766
|
_typedHandler: true;
|
131
767
|
_path: Path;
|
@@ -133,6 +769,68 @@ declare const middleware: <SV extends AnySchemaValidator, Path extends `/${strin
|
|
133
769
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
134
770
|
};
|
135
771
|
|
772
|
+
/**
|
773
|
+
* Creates an MKCACTIVITY route handler with schema validation and type safety.
|
774
|
+
*
|
775
|
+
* @template SV - The schema validator type
|
776
|
+
* @template Path - The route path type (must start with '/')
|
777
|
+
* @template P - The path parameters type
|
778
|
+
* @template ResBodyMap - The response body map type
|
779
|
+
* @template ReqBody - The request body type
|
780
|
+
* @template ReqQuery - The request query parameters type
|
781
|
+
* @template ReqHeaders - The request headers type
|
782
|
+
* @template ResHeaders - The response headers type
|
783
|
+
* @template LocalsObj - The locals object type
|
784
|
+
*
|
785
|
+
* @param {SV} schemaValidator - The schema validator instance
|
786
|
+
* @param {Path} path - The route path
|
787
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
788
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
789
|
+
*
|
790
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
791
|
+
*
|
792
|
+
* @example
|
793
|
+
* ```typescript
|
794
|
+
* mkcActivity(
|
795
|
+
* schemaValidator,
|
796
|
+
* '/activities',
|
797
|
+
* {
|
798
|
+
* summary: 'Create activity',
|
799
|
+
* description: 'Creates a new activity',
|
800
|
+
* tags: ['activities'],
|
801
|
+
* body: {
|
802
|
+
* type: 'object',
|
803
|
+
* properties: {
|
804
|
+
* name: { type: 'string' },
|
805
|
+
* type: { type: 'string' }
|
806
|
+
* }
|
807
|
+
* },
|
808
|
+
* responses: {
|
809
|
+
* 201: {
|
810
|
+
* description: 'Activity created successfully',
|
811
|
+
* content: {
|
812
|
+
* 'application/json': {
|
813
|
+
* schema: {
|
814
|
+
* type: 'object',
|
815
|
+
* properties: {
|
816
|
+
* id: { type: 'string' },
|
817
|
+
* name: { type: 'string' },
|
818
|
+
* type: { type: 'string' }
|
819
|
+
* }
|
820
|
+
* }
|
821
|
+
* }
|
822
|
+
* }
|
823
|
+
* }
|
824
|
+
* }
|
825
|
+
* },
|
826
|
+
* async (req, res) => {
|
827
|
+
* const { name, type } = req.body;
|
828
|
+
* // Create activity logic
|
829
|
+
* res.status(201).json({ id: 'act_123', name, type });
|
830
|
+
* }
|
831
|
+
* );
|
832
|
+
* ```
|
833
|
+
*/
|
136
834
|
declare const mkcActivity: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
137
835
|
_typedHandler: true;
|
138
836
|
_path: Path;
|
@@ -140,6 +838,68 @@ declare const mkcActivity: <SV extends AnySchemaValidator, Path extends `/${stri
|
|
140
838
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
141
839
|
};
|
142
840
|
|
841
|
+
/**
|
842
|
+
* Creates an MKCOL route handler with schema validation and type safety.
|
843
|
+
*
|
844
|
+
* @template SV - The schema validator type
|
845
|
+
* @template Path - The route path type (must start with '/')
|
846
|
+
* @template P - The path parameters type
|
847
|
+
* @template ResBodyMap - The response body map type
|
848
|
+
* @template ReqBody - The request body type
|
849
|
+
* @template ReqQuery - The request query parameters type
|
850
|
+
* @template ReqHeaders - The request headers type
|
851
|
+
* @template ResHeaders - The response headers type
|
852
|
+
* @template LocalsObj - The locals object type
|
853
|
+
*
|
854
|
+
* @param {SV} schemaValidator - The schema validator instance
|
855
|
+
* @param {Path} path - The route path
|
856
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
857
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
858
|
+
*
|
859
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
860
|
+
*
|
861
|
+
* @example
|
862
|
+
* ```typescript
|
863
|
+
* mkcol(
|
864
|
+
* schemaValidator,
|
865
|
+
* '/collections',
|
866
|
+
* {
|
867
|
+
* summary: 'Create collection',
|
868
|
+
* description: 'Creates a new collection',
|
869
|
+
* tags: ['collections'],
|
870
|
+
* body: {
|
871
|
+
* type: 'object',
|
872
|
+
* properties: {
|
873
|
+
* name: { type: 'string' },
|
874
|
+
* description: { type: 'string' }
|
875
|
+
* }
|
876
|
+
* },
|
877
|
+
* responses: {
|
878
|
+
* 201: {
|
879
|
+
* description: 'Collection created successfully',
|
880
|
+
* content: {
|
881
|
+
* 'application/json': {
|
882
|
+
* schema: {
|
883
|
+
* type: 'object',
|
884
|
+
* properties: {
|
885
|
+
* id: { type: 'string' },
|
886
|
+
* name: { type: 'string' },
|
887
|
+
* description: { type: 'string' }
|
888
|
+
* }
|
889
|
+
* }
|
890
|
+
* }
|
891
|
+
* }
|
892
|
+
* }
|
893
|
+
* }
|
894
|
+
* },
|
895
|
+
* async (req, res) => {
|
896
|
+
* const { name, description } = req.body;
|
897
|
+
* // Create collection logic
|
898
|
+
* res.status(201).json({ id: 'col_123', name, description });
|
899
|
+
* }
|
900
|
+
* );
|
901
|
+
* ```
|
902
|
+
*/
|
143
903
|
declare const mkcol: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
144
904
|
_typedHandler: true;
|
145
905
|
_path: Path;
|
@@ -147,6 +907,70 @@ declare const mkcol: <SV extends AnySchemaValidator, Path extends `/${string}`,
|
|
147
907
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
148
908
|
};
|
149
909
|
|
910
|
+
/**
|
911
|
+
* Creates a MOVE route handler with schema validation and type safety.
|
912
|
+
*
|
913
|
+
* @template SV - The schema validator type
|
914
|
+
* @template Path - The route path type (must start with '/')
|
915
|
+
* @template P - The path parameters type
|
916
|
+
* @template ResBodyMap - The response body map type
|
917
|
+
* @template ReqBody - The request body type
|
918
|
+
* @template ReqQuery - The request query parameters type
|
919
|
+
* @template ReqHeaders - The request headers type
|
920
|
+
* @template ResHeaders - The response headers type
|
921
|
+
* @template LocalsObj - The locals object type
|
922
|
+
*
|
923
|
+
* @param {SV} schemaValidator - The schema validator instance
|
924
|
+
* @param {Path} path - The route path
|
925
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
926
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
927
|
+
*
|
928
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
929
|
+
*
|
930
|
+
* @example
|
931
|
+
* ```typescript
|
932
|
+
* move(
|
933
|
+
* schemaValidator,
|
934
|
+
* '/resources/:id/move',
|
935
|
+
* {
|
936
|
+
* summary: 'Move resource',
|
937
|
+
* description: 'Moves a resource to a new location',
|
938
|
+
* tags: ['resources'],
|
939
|
+
* pathParams: {
|
940
|
+
* id: { type: 'string' }
|
941
|
+
* },
|
942
|
+
* body: {
|
943
|
+
* type: 'object',
|
944
|
+
* properties: {
|
945
|
+
* destination: { type: 'string' }
|
946
|
+
* }
|
947
|
+
* },
|
948
|
+
* responses: {
|
949
|
+
* 200: {
|
950
|
+
* description: 'Resource moved successfully',
|
951
|
+
* content: {
|
952
|
+
* 'application/json': {
|
953
|
+
* schema: {
|
954
|
+
* type: 'object',
|
955
|
+
* properties: {
|
956
|
+
* id: { type: 'string' },
|
957
|
+
* location: { type: 'string' }
|
958
|
+
* }
|
959
|
+
* }
|
960
|
+
* }
|
961
|
+
* }
|
962
|
+
* }
|
963
|
+
* }
|
964
|
+
* },
|
965
|
+
* async (req, res) => {
|
966
|
+
* const { id } = req.params;
|
967
|
+
* const { destination } = req.body;
|
968
|
+
* // Move logic
|
969
|
+
* res.json({ id, location: destination });
|
970
|
+
* }
|
971
|
+
* );
|
972
|
+
* ```
|
973
|
+
*/
|
150
974
|
declare const move: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
151
975
|
_typedHandler: true;
|
152
976
|
_path: Path;
|
@@ -154,6 +978,67 @@ declare const move: <SV extends AnySchemaValidator, Path extends `/${string}`, P
|
|
154
978
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
155
979
|
};
|
156
980
|
|
981
|
+
/**
|
982
|
+
* Creates a NOTIFY route handler with schema validation and type safety.
|
983
|
+
*
|
984
|
+
* @template SV - The schema validator type
|
985
|
+
* @template Path - The route path type (must start with '/')
|
986
|
+
* @template P - The path parameters type
|
987
|
+
* @template ResBodyMap - The response body map type
|
988
|
+
* @template ReqBody - The request body type
|
989
|
+
* @template ReqQuery - The request query parameters type
|
990
|
+
* @template ReqHeaders - The request headers type
|
991
|
+
* @template ResHeaders - The response headers type
|
992
|
+
* @template LocalsObj - The locals object type
|
993
|
+
*
|
994
|
+
* @param {SV} schemaValidator - The schema validator instance
|
995
|
+
* @param {Path} path - The route path
|
996
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
997
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
998
|
+
*
|
999
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1000
|
+
*
|
1001
|
+
* @example
|
1002
|
+
* ```typescript
|
1003
|
+
* notify(
|
1004
|
+
* schemaValidator,
|
1005
|
+
* '/notifications',
|
1006
|
+
* {
|
1007
|
+
* summary: 'Send notification',
|
1008
|
+
* description: 'Sends a notification to subscribers',
|
1009
|
+
* tags: ['notifications'],
|
1010
|
+
* body: {
|
1011
|
+
* type: 'object',
|
1012
|
+
* properties: {
|
1013
|
+
* message: { type: 'string' },
|
1014
|
+
* type: { type: 'string' }
|
1015
|
+
* }
|
1016
|
+
* },
|
1017
|
+
* responses: {
|
1018
|
+
* 200: {
|
1019
|
+
* description: 'Notification sent successfully',
|
1020
|
+
* content: {
|
1021
|
+
* 'application/json': {
|
1022
|
+
* schema: {
|
1023
|
+
* type: 'object',
|
1024
|
+
* properties: {
|
1025
|
+
* id: { type: 'string' },
|
1026
|
+
* status: { type: 'string' }
|
1027
|
+
* }
|
1028
|
+
* }
|
1029
|
+
* }
|
1030
|
+
* }
|
1031
|
+
* }
|
1032
|
+
* }
|
1033
|
+
* },
|
1034
|
+
* async (req, res) => {
|
1035
|
+
* const { message, type } = req.body;
|
1036
|
+
* // Notification logic
|
1037
|
+
* res.json({ id: 'not_123', status: 'sent' });
|
1038
|
+
* }
|
1039
|
+
* );
|
1040
|
+
* ```
|
1041
|
+
*/
|
157
1042
|
declare const notify: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
158
1043
|
_typedHandler: true;
|
159
1044
|
_path: Path;
|
@@ -161,12 +1046,258 @@ declare const notify: <SV extends AnySchemaValidator, Path extends `/${string}`,
|
|
161
1046
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
162
1047
|
};
|
163
1048
|
|
1049
|
+
/**
|
1050
|
+
* Creates an OPTIONS route handler with schema validation and type safety.
|
1051
|
+
*
|
1052
|
+
* @template SV - The schema validator type
|
1053
|
+
* @template Path - The route path type (must start with '/')
|
1054
|
+
* @template P - The path parameters type
|
1055
|
+
* @template ResBodyMap - The response body map type
|
1056
|
+
* @template ReqBody - The request body type
|
1057
|
+
* @template ReqQuery - The request query parameters type
|
1058
|
+
* @template ReqHeaders - The request headers type
|
1059
|
+
* @template ResHeaders - The response headers type
|
1060
|
+
* @template LocalsObj - The locals object type
|
1061
|
+
*
|
1062
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1063
|
+
* @param {Path} path - The route path
|
1064
|
+
* @param {ContractDetails<SV, 'options', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1065
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1066
|
+
*
|
1067
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1068
|
+
*
|
1069
|
+
* @example
|
1070
|
+
* ```typescript
|
1071
|
+
* options(
|
1072
|
+
* schemaValidator,
|
1073
|
+
* '/api',
|
1074
|
+
* {
|
1075
|
+
* summary: 'Get API options',
|
1076
|
+
* description: 'Returns the available HTTP methods and other options for the API',
|
1077
|
+
* tags: ['api'],
|
1078
|
+
* responses: {
|
1079
|
+
* 200: {
|
1080
|
+
* description: 'Available options',
|
1081
|
+
* content: {
|
1082
|
+
* 'application/json': {
|
1083
|
+
* schema: {
|
1084
|
+
* type: 'object',
|
1085
|
+
* properties: {
|
1086
|
+
* methods: {
|
1087
|
+
* type: 'array',
|
1088
|
+
* items: { type: 'string' }
|
1089
|
+
* },
|
1090
|
+
* cors: { type: 'boolean' }
|
1091
|
+
* }
|
1092
|
+
* }
|
1093
|
+
* }
|
1094
|
+
* }
|
1095
|
+
* }
|
1096
|
+
* }
|
1097
|
+
* },
|
1098
|
+
* async (req, res) => {
|
1099
|
+
* res.json({
|
1100
|
+
* methods: ['GET', 'POST', 'PUT', 'DELETE'],
|
1101
|
+
* cors: true
|
1102
|
+
* });
|
1103
|
+
* }
|
1104
|
+
* );
|
1105
|
+
* ```
|
1106
|
+
*/
|
164
1107
|
declare const options: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "options", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "options", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>;
|
165
1108
|
|
1109
|
+
/**
|
1110
|
+
* Creates a PATCH route handler with schema validation and type safety.
|
1111
|
+
*
|
1112
|
+
* @template SV - The schema validator type
|
1113
|
+
* @template Path - The route path type (must start with '/')
|
1114
|
+
* @template P - The path parameters type
|
1115
|
+
* @template ResBodyMap - The response body map type
|
1116
|
+
* @template ReqBody - The request body type
|
1117
|
+
* @template ReqQuery - The request query parameters type
|
1118
|
+
* @template ReqHeaders - The request headers type
|
1119
|
+
* @template ResHeaders - The response headers type
|
1120
|
+
* @template LocalsObj - The locals object type
|
1121
|
+
*
|
1122
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1123
|
+
* @param {Path} path - The route path
|
1124
|
+
* @param {ContractDetails<SV, 'patch', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1125
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1126
|
+
*
|
1127
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1128
|
+
*
|
1129
|
+
* @example
|
1130
|
+
* ```typescript
|
1131
|
+
* patch(
|
1132
|
+
* schemaValidator,
|
1133
|
+
* '/users/:id',
|
1134
|
+
* {
|
1135
|
+
* summary: 'Update user partially',
|
1136
|
+
* description: 'Updates specific fields of a user by ID',
|
1137
|
+
* tags: ['users'],
|
1138
|
+
* parameters: [
|
1139
|
+
* {
|
1140
|
+
* name: 'id',
|
1141
|
+
* in: 'path',
|
1142
|
+
* required: true,
|
1143
|
+
* schema: { type: 'string' }
|
1144
|
+
* }
|
1145
|
+
* ],
|
1146
|
+
* requestBody: {
|
1147
|
+
* content: {
|
1148
|
+
* 'application/json': {
|
1149
|
+
* schema: {
|
1150
|
+
* type: 'object',
|
1151
|
+
* properties: {
|
1152
|
+
* name: { type: 'string' },
|
1153
|
+
* email: { type: 'string' }
|
1154
|
+
* }
|
1155
|
+
* }
|
1156
|
+
* }
|
1157
|
+
* }
|
1158
|
+
* },
|
1159
|
+
* responses: {
|
1160
|
+
* 200: {
|
1161
|
+
* description: 'User updated successfully',
|
1162
|
+
* content: {
|
1163
|
+
* 'application/json': {
|
1164
|
+
* schema: {
|
1165
|
+
* type: 'object',
|
1166
|
+
* properties: {
|
1167
|
+
* id: { type: 'string' },
|
1168
|
+
* name: { type: 'string' },
|
1169
|
+
* email: { type: 'string' }
|
1170
|
+
* }
|
1171
|
+
* }
|
1172
|
+
* }
|
1173
|
+
* }
|
1174
|
+
* }
|
1175
|
+
* }
|
1176
|
+
* },
|
1177
|
+
* async (req, res) => {
|
1178
|
+
* const { id } = req.params;
|
1179
|
+
* const updates = req.body;
|
1180
|
+
* const user = await updateUser(id, updates);
|
1181
|
+
* res.json(user);
|
1182
|
+
* }
|
1183
|
+
* );
|
1184
|
+
* ```
|
1185
|
+
*/
|
166
1186
|
declare const patch: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "patch", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "patch", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>;
|
167
1187
|
|
1188
|
+
/**
|
1189
|
+
* Creates a POST route handler with schema validation and type safety.
|
1190
|
+
*
|
1191
|
+
* @template SV - Schema validator type extending AnySchemaValidator
|
1192
|
+
* @template Path - Route path type extending string with leading slash
|
1193
|
+
* @template P - Parameters object type extending ParamsObject
|
1194
|
+
* @template ResBodyMap - Response body map type extending ResponsesObject
|
1195
|
+
* @template ReqBody - Request body type extending Body
|
1196
|
+
* @template ReqQuery - Request query type extending QueryObject
|
1197
|
+
* @template ReqHeaders - Request headers type extending HeadersObject
|
1198
|
+
* @template ResHeaders - Response headers type extending HeadersObject
|
1199
|
+
* @template LocalsObj - Local variables type extending Record<string, unknown>
|
1200
|
+
*
|
1201
|
+
* @param {SV} schemaValidator - Schema validator instance
|
1202
|
+
* @param {Path} path - Route path starting with '/'
|
1203
|
+
* @param {ContractDetails} contractDetails - Contract details for route validation
|
1204
|
+
* @param {...ExpressLikeSchemaHandler[]} handlers - Route handler middleware functions
|
1205
|
+
* @returns {Function} Express route handler with schema validation
|
1206
|
+
*
|
1207
|
+
* @example
|
1208
|
+
* ```typescript
|
1209
|
+
* const createUser = post(
|
1210
|
+
* schemaValidator,
|
1211
|
+
* '/users',
|
1212
|
+
* {
|
1213
|
+
* body: {
|
1214
|
+
* type: 'object',
|
1215
|
+
* properties: { name: { type: 'string' } },
|
1216
|
+
* required: ['name']
|
1217
|
+
* },
|
1218
|
+
* responses: {
|
1219
|
+
* 201: { type: 'object', properties: { id: { type: 'string' } } }
|
1220
|
+
* }
|
1221
|
+
* },
|
1222
|
+
* async (req, res) => {
|
1223
|
+
* const user = await createNewUser(req.body);
|
1224
|
+
* res.status(201).json(user);
|
1225
|
+
* }
|
1226
|
+
* );
|
1227
|
+
* ```
|
1228
|
+
*/
|
168
1229
|
declare const post: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "post", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "post", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>;
|
169
1230
|
|
1231
|
+
/**
|
1232
|
+
* Creates a PROPFIND route handler with schema validation and type safety.
|
1233
|
+
*
|
1234
|
+
* @template SV - The schema validator type
|
1235
|
+
* @template Path - The route path type (must start with '/')
|
1236
|
+
* @template P - The path parameters type
|
1237
|
+
* @template ResBodyMap - The response body map type
|
1238
|
+
* @template ReqBody - The request body type
|
1239
|
+
* @template ReqQuery - The request query parameters type
|
1240
|
+
* @template ReqHeaders - The request headers type
|
1241
|
+
* @template ResHeaders - The response headers type
|
1242
|
+
* @template LocalsObj - The locals object type
|
1243
|
+
*
|
1244
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1245
|
+
* @param {Path} path - The route path
|
1246
|
+
* @param {ContractDetails<SV, 'propfind', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1247
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1248
|
+
*
|
1249
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1250
|
+
*
|
1251
|
+
* @example
|
1252
|
+
* ```typescript
|
1253
|
+
* propfind(
|
1254
|
+
* schemaValidator,
|
1255
|
+
* '/resources/:id',
|
1256
|
+
* {
|
1257
|
+
* summary: 'Get resource properties',
|
1258
|
+
* description: 'Retrieves properties of a resource',
|
1259
|
+
* tags: ['resources'],
|
1260
|
+
* parameters: [
|
1261
|
+
* {
|
1262
|
+
* name: 'id',
|
1263
|
+
* in: 'path',
|
1264
|
+
* required: true,
|
1265
|
+
* schema: { type: 'string' }
|
1266
|
+
* }
|
1267
|
+
* ],
|
1268
|
+
* requestBody: {
|
1269
|
+
* content: {
|
1270
|
+
* 'application/xml': {
|
1271
|
+
* schema: {
|
1272
|
+
* type: 'string',
|
1273
|
+
* description: 'XML request body with property names to retrieve'
|
1274
|
+
* }
|
1275
|
+
* }
|
1276
|
+
* }
|
1277
|
+
* },
|
1278
|
+
* responses: {
|
1279
|
+
* 207: {
|
1280
|
+
* description: 'Multi-status response with property values',
|
1281
|
+
* content: {
|
1282
|
+
* 'application/xml': {
|
1283
|
+
* schema: {
|
1284
|
+
* type: 'string',
|
1285
|
+
* description: 'XML response with property values'
|
1286
|
+
* }
|
1287
|
+
* }
|
1288
|
+
* }
|
1289
|
+
* }
|
1290
|
+
* }
|
1291
|
+
* },
|
1292
|
+
* async (req, res) => {
|
1293
|
+
* const { id } = req.params;
|
1294
|
+
* const xmlRequest = req.body;
|
1295
|
+
* const properties = await getResourceProperties(id, xmlRequest);
|
1296
|
+
* res.status(207).type('application/xml').send(properties);
|
1297
|
+
* }
|
1298
|
+
* );
|
1299
|
+
* ```
|
1300
|
+
*/
|
170
1301
|
declare const propfind: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
171
1302
|
_typedHandler: true;
|
172
1303
|
_path: Path;
|
@@ -174,6 +1305,76 @@ declare const propfind: <SV extends AnySchemaValidator, Path extends `/${string}
|
|
174
1305
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
175
1306
|
};
|
176
1307
|
|
1308
|
+
/**
|
1309
|
+
* Creates a PROPPATCH route handler with schema validation and type safety.
|
1310
|
+
*
|
1311
|
+
* @template SV - The schema validator type
|
1312
|
+
* @template Path - The route path type (must start with '/')
|
1313
|
+
* @template P - The path parameters type
|
1314
|
+
* @template ResBodyMap - The response body map type
|
1315
|
+
* @template ReqBody - The request body type
|
1316
|
+
* @template ReqQuery - The request query parameters type
|
1317
|
+
* @template ReqHeaders - The request headers type
|
1318
|
+
* @template ResHeaders - The response headers type
|
1319
|
+
* @template LocalsObj - The locals object type
|
1320
|
+
*
|
1321
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1322
|
+
* @param {Path} path - The route path
|
1323
|
+
* @param {ContractDetails<SV, 'proppatch', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1324
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1325
|
+
*
|
1326
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1327
|
+
*
|
1328
|
+
* @example
|
1329
|
+
* ```typescript
|
1330
|
+
* proppatch(
|
1331
|
+
* schemaValidator,
|
1332
|
+
* '/resources/:id',
|
1333
|
+
* {
|
1334
|
+
* summary: 'Update resource properties',
|
1335
|
+
* description: 'Updates properties of a resource',
|
1336
|
+
* tags: ['resources'],
|
1337
|
+
* parameters: [
|
1338
|
+
* {
|
1339
|
+
* name: 'id',
|
1340
|
+
* in: 'path',
|
1341
|
+
* required: true,
|
1342
|
+
* schema: { type: 'string' }
|
1343
|
+
* }
|
1344
|
+
* ],
|
1345
|
+
* requestBody: {
|
1346
|
+
* content: {
|
1347
|
+
* 'application/xml': {
|
1348
|
+
* schema: {
|
1349
|
+
* type: 'string',
|
1350
|
+
* description: 'XML request body with property updates'
|
1351
|
+
* }
|
1352
|
+
* }
|
1353
|
+
* }
|
1354
|
+
* },
|
1355
|
+
* responses: {
|
1356
|
+
* 207: {
|
1357
|
+
* description: 'Multi-status response with property update results',
|
1358
|
+
* content: {
|
1359
|
+
* 'application/xml': {
|
1360
|
+
* schema: {
|
1361
|
+
* type: 'string',
|
1362
|
+
* description: 'XML response with property update status'
|
1363
|
+
* }
|
1364
|
+
* }
|
1365
|
+
* }
|
1366
|
+
* }
|
1367
|
+
* }
|
1368
|
+
* },
|
1369
|
+
* async (req, res) => {
|
1370
|
+
* const { id } = req.params;
|
1371
|
+
* const xmlRequest = req.body;
|
1372
|
+
* const result = await updateResourceProperties(id, xmlRequest);
|
1373
|
+
* res.status(207).type('application/xml').send(result);
|
1374
|
+
* }
|
1375
|
+
* );
|
1376
|
+
* ```
|
1377
|
+
*/
|
177
1378
|
declare const proppatch: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
178
1379
|
_typedHandler: true;
|
179
1380
|
_path: Path;
|
@@ -181,6 +1382,56 @@ declare const proppatch: <SV extends AnySchemaValidator, Path extends `/${string
|
|
181
1382
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
182
1383
|
};
|
183
1384
|
|
1385
|
+
/**
|
1386
|
+
* Creates a PURGE route handler with schema validation and type safety.
|
1387
|
+
*
|
1388
|
+
* @template SV - The schema validator type
|
1389
|
+
* @template Path - The route path type (must start with '/')
|
1390
|
+
* @template P - The path parameters type
|
1391
|
+
* @template ResBodyMap - The response body map type
|
1392
|
+
* @template ReqQuery - The request query parameters type
|
1393
|
+
* @template ReqHeaders - The request headers type
|
1394
|
+
* @template ResHeaders - The response headers type
|
1395
|
+
* @template LocalsObj - The locals object type
|
1396
|
+
*
|
1397
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1398
|
+
* @param {Path} path - The route path
|
1399
|
+
* @param {ContractDetails<SV, 'purge', Path, P, ResBodyMap, never, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1400
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, never, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1401
|
+
*
|
1402
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1403
|
+
*
|
1404
|
+
* @example
|
1405
|
+
* ```typescript
|
1406
|
+
* purge(
|
1407
|
+
* schemaValidator,
|
1408
|
+
* '/cache/:id',
|
1409
|
+
* {
|
1410
|
+
* summary: 'Purge cache',
|
1411
|
+
* description: 'Removes an item from the cache',
|
1412
|
+
* tags: ['cache'],
|
1413
|
+
* parameters: [
|
1414
|
+
* {
|
1415
|
+
* name: 'id',
|
1416
|
+
* in: 'path',
|
1417
|
+
* required: true,
|
1418
|
+
* schema: { type: 'string' }
|
1419
|
+
* }
|
1420
|
+
* ],
|
1421
|
+
* responses: {
|
1422
|
+
* 204: {
|
1423
|
+
* description: 'Cache item purged successfully'
|
1424
|
+
* }
|
1425
|
+
* }
|
1426
|
+
* },
|
1427
|
+
* async (req, res) => {
|
1428
|
+
* const { id } = req.params;
|
1429
|
+
* await purgeCacheItem(id);
|
1430
|
+
* res.status(204).send();
|
1431
|
+
* }
|
1432
|
+
* );
|
1433
|
+
* ```
|
1434
|
+
*/
|
184
1435
|
declare const purge: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
185
1436
|
_typedHandler: true;
|
186
1437
|
_path: Path;
|
@@ -188,8 +1439,129 @@ declare const purge: <SV extends AnySchemaValidator, Path extends `/${string}`,
|
|
188
1439
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
189
1440
|
};
|
190
1441
|
|
1442
|
+
/**
|
1443
|
+
* Creates a PUT route handler with schema validation and type safety.
|
1444
|
+
*
|
1445
|
+
* @template SV - The schema validator type
|
1446
|
+
* @template Path - The route path type (must start with '/')
|
1447
|
+
* @template P - The path parameters type
|
1448
|
+
* @template ResBodyMap - The response body map type
|
1449
|
+
* @template ReqBody - The request body type
|
1450
|
+
* @template ReqQuery - The request query parameters type
|
1451
|
+
* @template ReqHeaders - The request headers type
|
1452
|
+
* @template ResHeaders - The response headers type
|
1453
|
+
* @template LocalsObj - The locals object type
|
1454
|
+
*
|
1455
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1456
|
+
* @param {Path} path - The route path
|
1457
|
+
* @param {ContractDetails<SV, 'put', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1458
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1459
|
+
*
|
1460
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1461
|
+
*
|
1462
|
+
* @example
|
1463
|
+
* ```typescript
|
1464
|
+
* put(
|
1465
|
+
* schemaValidator,
|
1466
|
+
* '/users/:id',
|
1467
|
+
* {
|
1468
|
+
* summary: 'Update user',
|
1469
|
+
* description: 'Updates a user by ID',
|
1470
|
+
* tags: ['users'],
|
1471
|
+
* pathParams: {
|
1472
|
+
* id: { type: 'string' }
|
1473
|
+
* },
|
1474
|
+
* body: {
|
1475
|
+
* type: 'object',
|
1476
|
+
* properties: {
|
1477
|
+
* name: { type: 'string' }
|
1478
|
+
* }
|
1479
|
+
* },
|
1480
|
+
* responses: {
|
1481
|
+
* 200: {
|
1482
|
+
* description: 'User updated successfully',
|
1483
|
+
* content: {
|
1484
|
+
* 'application/json': {
|
1485
|
+
* schema: {
|
1486
|
+
* type: 'object',
|
1487
|
+
* properties: {
|
1488
|
+
* id: { type: 'string' },
|
1489
|
+
* name: { type: 'string' }
|
1490
|
+
* }
|
1491
|
+
* }
|
1492
|
+
* }
|
1493
|
+
* }
|
1494
|
+
* }
|
1495
|
+
* }
|
1496
|
+
* },
|
1497
|
+
* async (req, res) => {
|
1498
|
+
* const { id } = req.params;
|
1499
|
+
* const { name } = req.body;
|
1500
|
+
* // Update user logic
|
1501
|
+
* res.json({ id, name });
|
1502
|
+
* }
|
1503
|
+
* );
|
1504
|
+
* ```
|
1505
|
+
*/
|
191
1506
|
declare const put: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "put", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "put", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>;
|
192
1507
|
|
1508
|
+
/**
|
1509
|
+
* Creates a REPORT route handler with schema validation and type safety.
|
1510
|
+
*
|
1511
|
+
* @template SV - The schema validator type
|
1512
|
+
* @template Path - The route path type (must start with '/')
|
1513
|
+
* @template P - The path parameters type
|
1514
|
+
* @template ResBodyMap - The response body map type
|
1515
|
+
* @template ReqBody - The request body type
|
1516
|
+
* @template ReqQuery - The request query parameters type
|
1517
|
+
* @template ReqHeaders - The request headers type
|
1518
|
+
* @template ResHeaders - The response headers type
|
1519
|
+
* @template LocalsObj - The locals object type
|
1520
|
+
*
|
1521
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1522
|
+
* @param {Path} path - The route path
|
1523
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1524
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1525
|
+
*
|
1526
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1527
|
+
*
|
1528
|
+
* @example
|
1529
|
+
* ```typescript
|
1530
|
+
* report(
|
1531
|
+
* schemaValidator,
|
1532
|
+
* '/reports/:id',
|
1533
|
+
* {
|
1534
|
+
* summary: 'Generate report',
|
1535
|
+
* description: 'Generates a report for the specified resource',
|
1536
|
+
* tags: ['reports'],
|
1537
|
+
* pathParams: {
|
1538
|
+
* id: { type: 'string' }
|
1539
|
+
* },
|
1540
|
+
* responses: {
|
1541
|
+
* 200: {
|
1542
|
+
* description: 'Report generated successfully',
|
1543
|
+
* content: {
|
1544
|
+
* 'application/json': {
|
1545
|
+
* schema: {
|
1546
|
+
* type: 'object',
|
1547
|
+
* properties: {
|
1548
|
+
* id: { type: 'string' },
|
1549
|
+
* status: { type: 'string' }
|
1550
|
+
* }
|
1551
|
+
* }
|
1552
|
+
* }
|
1553
|
+
* }
|
1554
|
+
* }
|
1555
|
+
* }
|
1556
|
+
* },
|
1557
|
+
* async (req, res) => {
|
1558
|
+
* const { id } = req.params;
|
1559
|
+
* // Generate report logic
|
1560
|
+
* res.json({ id, status: 'completed' });
|
1561
|
+
* }
|
1562
|
+
* );
|
1563
|
+
* ```
|
1564
|
+
*/
|
193
1565
|
declare const report: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
194
1566
|
_typedHandler: true;
|
195
1567
|
_path: Path;
|
@@ -197,6 +1569,75 @@ declare const report: <SV extends AnySchemaValidator, Path extends `/${string}`,
|
|
197
1569
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
198
1570
|
};
|
199
1571
|
|
1572
|
+
/**
|
1573
|
+
* Creates a SEARCH route handler with schema validation and type safety.
|
1574
|
+
*
|
1575
|
+
* @template SV - The schema validator type
|
1576
|
+
* @template Path - The route path type (must start with '/')
|
1577
|
+
* @template P - The path parameters type
|
1578
|
+
* @template ResBodyMap - The response body map type
|
1579
|
+
* @template ReqBody - The request body type
|
1580
|
+
* @template ReqQuery - The request query parameters type
|
1581
|
+
* @template ReqHeaders - The request headers type
|
1582
|
+
* @template ResHeaders - The response headers type
|
1583
|
+
* @template LocalsObj - The locals object type
|
1584
|
+
*
|
1585
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1586
|
+
* @param {Path} path - The route path
|
1587
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1588
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1589
|
+
*
|
1590
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1591
|
+
*
|
1592
|
+
* @example
|
1593
|
+
* ```typescript
|
1594
|
+
* search(
|
1595
|
+
* schemaValidator,
|
1596
|
+
* '/search',
|
1597
|
+
* {
|
1598
|
+
* summary: 'Search resources',
|
1599
|
+
* description: 'Searches for resources based on query parameters',
|
1600
|
+
* tags: ['search'],
|
1601
|
+
* query: {
|
1602
|
+
* type: 'object',
|
1603
|
+
* properties: {
|
1604
|
+
* q: { type: 'string' },
|
1605
|
+
* limit: { type: 'number' }
|
1606
|
+
* }
|
1607
|
+
* },
|
1608
|
+
* responses: {
|
1609
|
+
* 200: {
|
1610
|
+
* description: 'Search results',
|
1611
|
+
* content: {
|
1612
|
+
* 'application/json': {
|
1613
|
+
* schema: {
|
1614
|
+
* type: 'object',
|
1615
|
+
* properties: {
|
1616
|
+
* results: {
|
1617
|
+
* type: 'array',
|
1618
|
+
* items: {
|
1619
|
+
* type: 'object',
|
1620
|
+
* properties: {
|
1621
|
+
* id: { type: 'string' },
|
1622
|
+
* title: { type: 'string' }
|
1623
|
+
* }
|
1624
|
+
* }
|
1625
|
+
* }
|
1626
|
+
* }
|
1627
|
+
* }
|
1628
|
+
* }
|
1629
|
+
* }
|
1630
|
+
* }
|
1631
|
+
* }
|
1632
|
+
* },
|
1633
|
+
* async (req, res) => {
|
1634
|
+
* const { q, limit } = req.query;
|
1635
|
+
* // Search logic
|
1636
|
+
* res.json({ results: [] });
|
1637
|
+
* }
|
1638
|
+
* );
|
1639
|
+
* ```
|
1640
|
+
*/
|
200
1641
|
declare const search: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
201
1642
|
_typedHandler: true;
|
202
1643
|
_path: Path;
|
@@ -204,6 +1645,67 @@ declare const search: <SV extends AnySchemaValidator, Path extends `/${string}`,
|
|
204
1645
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
205
1646
|
};
|
206
1647
|
|
1648
|
+
/**
|
1649
|
+
* Creates a SUBSCRIBE route handler with schema validation and type safety.
|
1650
|
+
*
|
1651
|
+
* @template SV - The schema validator type
|
1652
|
+
* @template Path - The route path type (must start with '/')
|
1653
|
+
* @template P - The path parameters type
|
1654
|
+
* @template ResBodyMap - The response body map type
|
1655
|
+
* @template ReqBody - The request body type
|
1656
|
+
* @template ReqQuery - The request query parameters type
|
1657
|
+
* @template ReqHeaders - The request headers type
|
1658
|
+
* @template ResHeaders - The response headers type
|
1659
|
+
* @template LocalsObj - The locals object type
|
1660
|
+
*
|
1661
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1662
|
+
* @param {Path} path - The route path
|
1663
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1664
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1665
|
+
*
|
1666
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1667
|
+
*
|
1668
|
+
* @example
|
1669
|
+
* ```typescript
|
1670
|
+
* subscribe(
|
1671
|
+
* schemaValidator,
|
1672
|
+
* '/subscribe',
|
1673
|
+
* {
|
1674
|
+
* summary: 'Subscribe to updates',
|
1675
|
+
* description: 'Subscribes to receive updates for a resource',
|
1676
|
+
* tags: ['subscriptions'],
|
1677
|
+
* body: {
|
1678
|
+
* type: 'object',
|
1679
|
+
* properties: {
|
1680
|
+
* email: { type: 'string' },
|
1681
|
+
* resourceId: { type: 'string' }
|
1682
|
+
* }
|
1683
|
+
* },
|
1684
|
+
* responses: {
|
1685
|
+
* 200: {
|
1686
|
+
* description: 'Subscription created successfully',
|
1687
|
+
* content: {
|
1688
|
+
* 'application/json': {
|
1689
|
+
* schema: {
|
1690
|
+
* type: 'object',
|
1691
|
+
* properties: {
|
1692
|
+
* id: { type: 'string' },
|
1693
|
+
* status: { type: 'string' }
|
1694
|
+
* }
|
1695
|
+
* }
|
1696
|
+
* }
|
1697
|
+
* }
|
1698
|
+
* }
|
1699
|
+
* }
|
1700
|
+
* },
|
1701
|
+
* async (req, res) => {
|
1702
|
+
* const { email, resourceId } = req.body;
|
1703
|
+
* // Subscription logic
|
1704
|
+
* res.json({ id: 'sub_123', status: 'active' });
|
1705
|
+
* }
|
1706
|
+
* );
|
1707
|
+
* ```
|
1708
|
+
*/
|
207
1709
|
declare const subscribe: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
208
1710
|
_typedHandler: true;
|
209
1711
|
_path: Path;
|
@@ -211,8 +1713,115 @@ declare const subscribe: <SV extends AnySchemaValidator, Path extends `/${string
|
|
211
1713
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
212
1714
|
};
|
213
1715
|
|
1716
|
+
/**
|
1717
|
+
* Creates a TRACE route handler with schema validation and type safety.
|
1718
|
+
*
|
1719
|
+
* @template SV - The schema validator type
|
1720
|
+
* @template Path - The route path type (must start with '/')
|
1721
|
+
* @template P - The path parameters type
|
1722
|
+
* @template ResBodyMap - The response body map type
|
1723
|
+
* @template ReqBody - The request body type
|
1724
|
+
* @template ReqQuery - The request query parameters type
|
1725
|
+
* @template ReqHeaders - The request headers type
|
1726
|
+
* @template ResHeaders - The response headers type
|
1727
|
+
* @template LocalsObj - The locals object type
|
1728
|
+
*
|
1729
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1730
|
+
* @param {Path} path - The route path
|
1731
|
+
* @param {ContractDetails<SV, 'trace', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1732
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1733
|
+
*
|
1734
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1735
|
+
*
|
1736
|
+
* @example
|
1737
|
+
* ```typescript
|
1738
|
+
* trace(
|
1739
|
+
* schemaValidator,
|
1740
|
+
* '/trace',
|
1741
|
+
* {
|
1742
|
+
* summary: 'Trace request',
|
1743
|
+
* description: 'Traces the request path and returns diagnostic information',
|
1744
|
+
* tags: ['diagnostics'],
|
1745
|
+
* responses: {
|
1746
|
+
* 200: {
|
1747
|
+
* description: 'Trace information',
|
1748
|
+
* content: {
|
1749
|
+
* 'message/http': {
|
1750
|
+
* schema: {
|
1751
|
+
* type: 'string'
|
1752
|
+
* }
|
1753
|
+
* }
|
1754
|
+
* }
|
1755
|
+
* }
|
1756
|
+
* }
|
1757
|
+
* },
|
1758
|
+
* async (req, res) => {
|
1759
|
+
* // Trace logic
|
1760
|
+
* res.set('Content-Type', 'message/http');
|
1761
|
+
* res.send('TRACE /trace HTTP/1.1');
|
1762
|
+
* }
|
1763
|
+
* );
|
1764
|
+
* ```
|
1765
|
+
*/
|
214
1766
|
declare const trace: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "trace", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => _forklaunch_core_http.ExpressLikeTypedHandler<SV, "trace", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>;
|
215
1767
|
|
1768
|
+
/**
|
1769
|
+
* Creates an UNLINK route handler with schema validation and type safety.
|
1770
|
+
*
|
1771
|
+
* @template SV - The schema validator type
|
1772
|
+
* @template Path - The route path type (must start with '/')
|
1773
|
+
* @template P - The path parameters type
|
1774
|
+
* @template ResBodyMap - The response body map type
|
1775
|
+
* @template ReqBody - The request body type
|
1776
|
+
* @template ReqQuery - The request query parameters type
|
1777
|
+
* @template ReqHeaders - The request headers type
|
1778
|
+
* @template ResHeaders - The response headers type
|
1779
|
+
* @template LocalsObj - The locals object type
|
1780
|
+
*
|
1781
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1782
|
+
* @param {Path} path - The route path
|
1783
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1784
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1785
|
+
*
|
1786
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1787
|
+
*
|
1788
|
+
* @example
|
1789
|
+
* ```typescript
|
1790
|
+
* unlink(
|
1791
|
+
* schemaValidator,
|
1792
|
+
* '/resources/:id/link',
|
1793
|
+
* {
|
1794
|
+
* summary: 'Unlink resource',
|
1795
|
+
* description: 'Removes a link between two resources',
|
1796
|
+
* tags: ['resources'],
|
1797
|
+
* pathParams: {
|
1798
|
+
* id: { type: 'string' }
|
1799
|
+
* },
|
1800
|
+
* responses: {
|
1801
|
+
* 200: {
|
1802
|
+
* description: 'Resource unlinked successfully',
|
1803
|
+
* content: {
|
1804
|
+
* 'application/json': {
|
1805
|
+
* schema: {
|
1806
|
+
* type: 'object',
|
1807
|
+
* properties: {
|
1808
|
+
* id: { type: 'string' },
|
1809
|
+
* status: { type: 'string' }
|
1810
|
+
* }
|
1811
|
+
* }
|
1812
|
+
* }
|
1813
|
+
* }
|
1814
|
+
* }
|
1815
|
+
* }
|
1816
|
+
* },
|
1817
|
+
* async (req, res) => {
|
1818
|
+
* const { id } = req.params;
|
1819
|
+
* // Unlink logic
|
1820
|
+
* res.json({ id, status: 'unlinked' });
|
1821
|
+
* }
|
1822
|
+
* );
|
1823
|
+
* ```
|
1824
|
+
*/
|
216
1825
|
declare const unlink: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
217
1826
|
_typedHandler: true;
|
218
1827
|
_path: Path;
|
@@ -220,6 +1829,63 @@ declare const unlink: <SV extends AnySchemaValidator, Path extends `/${string}`,
|
|
220
1829
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
221
1830
|
};
|
222
1831
|
|
1832
|
+
/**
|
1833
|
+
* Creates an UNLOCK route handler with schema validation and type safety.
|
1834
|
+
*
|
1835
|
+
* @template SV - The schema validator type
|
1836
|
+
* @template Path - The route path type (must start with '/')
|
1837
|
+
* @template P - The path parameters type
|
1838
|
+
* @template ResBodyMap - The response body map type
|
1839
|
+
* @template ReqBody - The request body type
|
1840
|
+
* @template ReqQuery - The request query parameters type
|
1841
|
+
* @template ReqHeaders - The request headers type
|
1842
|
+
* @template ResHeaders - The response headers type
|
1843
|
+
* @template LocalsObj - The locals object type
|
1844
|
+
*
|
1845
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1846
|
+
* @param {Path} path - The route path
|
1847
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1848
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1849
|
+
*
|
1850
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1851
|
+
*
|
1852
|
+
* @example
|
1853
|
+
* ```typescript
|
1854
|
+
* unlock(
|
1855
|
+
* schemaValidator,
|
1856
|
+
* '/resources/:id/lock',
|
1857
|
+
* {
|
1858
|
+
* summary: 'Unlock resource',
|
1859
|
+
* description: 'Removes a lock from a resource',
|
1860
|
+
* tags: ['resources'],
|
1861
|
+
* pathParams: {
|
1862
|
+
* id: { type: 'string' }
|
1863
|
+
* },
|
1864
|
+
* responses: {
|
1865
|
+
* 200: {
|
1866
|
+
* description: 'Resource unlocked successfully',
|
1867
|
+
* content: {
|
1868
|
+
* 'application/json': {
|
1869
|
+
* schema: {
|
1870
|
+
* type: 'object',
|
1871
|
+
* properties: {
|
1872
|
+
* id: { type: 'string' },
|
1873
|
+
* status: { type: 'string' }
|
1874
|
+
* }
|
1875
|
+
* }
|
1876
|
+
* }
|
1877
|
+
* }
|
1878
|
+
* }
|
1879
|
+
* }
|
1880
|
+
* },
|
1881
|
+
* async (req, res) => {
|
1882
|
+
* const { id } = req.params;
|
1883
|
+
* // Unlock logic
|
1884
|
+
* res.json({ id, status: 'unlocked' });
|
1885
|
+
* }
|
1886
|
+
* );
|
1887
|
+
* ```
|
1888
|
+
*/
|
223
1889
|
declare const unlock: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
224
1890
|
_typedHandler: true;
|
225
1891
|
_path: Path;
|
@@ -227,6 +1893,63 @@ declare const unlock: <SV extends AnySchemaValidator, Path extends `/${string}`,
|
|
227
1893
|
handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>>, Response<any, Record<string, any>>, NextFunction>[];
|
228
1894
|
};
|
229
1895
|
|
1896
|
+
/**
|
1897
|
+
* Creates an UNSUBSCRIBE route handler with schema validation and type safety.
|
1898
|
+
*
|
1899
|
+
* @template SV - The schema validator type
|
1900
|
+
* @template Path - The route path type (must start with '/')
|
1901
|
+
* @template P - The path parameters type
|
1902
|
+
* @template ResBodyMap - The response body map type
|
1903
|
+
* @template ReqBody - The request body type
|
1904
|
+
* @template ReqQuery - The request query parameters type
|
1905
|
+
* @template ReqHeaders - The request headers type
|
1906
|
+
* @template ResHeaders - The response headers type
|
1907
|
+
* @template LocalsObj - The locals object type
|
1908
|
+
*
|
1909
|
+
* @param {SV} schemaValidator - The schema validator instance
|
1910
|
+
* @param {Path} path - The route path
|
1911
|
+
* @param {ContractDetails<SV, 'middleware', Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>} contractDetails - The contract details for the route
|
1912
|
+
* @param {...ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]} handlers - The route handlers
|
1913
|
+
*
|
1914
|
+
* @returns {void} - Returns nothing, registers the route with Express
|
1915
|
+
*
|
1916
|
+
* @example
|
1917
|
+
* ```typescript
|
1918
|
+
* unsubscribe(
|
1919
|
+
* schemaValidator,
|
1920
|
+
* '/subscriptions/:id',
|
1921
|
+
* {
|
1922
|
+
* summary: 'Unsubscribe from updates',
|
1923
|
+
* description: 'Removes a subscription to resource updates',
|
1924
|
+
* tags: ['subscriptions'],
|
1925
|
+
* pathParams: {
|
1926
|
+
* id: { type: 'string' }
|
1927
|
+
* },
|
1928
|
+
* responses: {
|
1929
|
+
* 200: {
|
1930
|
+
* description: 'Subscription removed successfully',
|
1931
|
+
* content: {
|
1932
|
+
* 'application/json': {
|
1933
|
+
* schema: {
|
1934
|
+
* type: 'object',
|
1935
|
+
* properties: {
|
1936
|
+
* id: { type: 'string' },
|
1937
|
+
* status: { type: 'string' }
|
1938
|
+
* }
|
1939
|
+
* }
|
1940
|
+
* }
|
1941
|
+
* }
|
1942
|
+
* }
|
1943
|
+
* }
|
1944
|
+
* },
|
1945
|
+
* async (req, res) => {
|
1946
|
+
* const { id } = req.params;
|
1947
|
+
* // Unsubscribe logic
|
1948
|
+
* res.json({ id, status: 'unsubscribed' });
|
1949
|
+
* }
|
1950
|
+
* );
|
1951
|
+
* ```
|
1952
|
+
*/
|
230
1953
|
declare const unsubscribe: <SV extends AnySchemaValidator, Path extends `/${string}`, P extends ParamsObject<SV>, ResBodyMap extends ResponsesObject<SV>, ReqBody extends Body<SV>, ReqQuery extends QueryObject<SV>, ReqHeaders extends HeadersObject<SV>, ResHeaders extends HeadersObject<SV>, LocalsObj extends Record<string, unknown>>(schemaValidator: SV, path: Path, contractDetails: ContractDetails<SV, "middleware", Path, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, Request>, ...handlers: ExpressLikeSchemaHandler<SV, P, ResBodyMap, ReqBody, ReqQuery, ReqHeaders, ResHeaders, LocalsObj, Request, Response, NextFunction>[]) => {
|
231
1954
|
_typedHandler: true;
|
232
1955
|
_path: Path;
|