@athenna/http 3.0.11 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/Commands/MakeControllerCommand.d.ts +15 -0
- package/build/Commands/MakeControllerCommand.js +42 -0
- package/build/Commands/MakeInterceptorCommand.d.ts +15 -0
- package/build/Commands/MakeInterceptorCommand.js +42 -0
- package/build/Commands/MakeMiddlewareCommand.d.ts +15 -0
- package/build/Commands/MakeMiddlewareCommand.js +42 -0
- package/build/Commands/MakeTerminatorCommand.d.ts +15 -0
- package/build/Commands/MakeTerminatorCommand.js +42 -0
- package/build/Commands/RouteListCommand.d.ts +19 -0
- package/build/Commands/RouteListCommand.js +62 -0
- package/build/Context/Request.d.ts +144 -0
- package/build/Context/Request.js +219 -0
- package/build/Context/Response.d.ts +67 -0
- package/build/Context/Response.js +102 -0
- package/build/Contracts/InterceptorContract.d.ts +15 -0
- package/build/Contracts/InterceptorContract.js +9 -0
- package/build/Contracts/MiddlewareContract.d.ts +15 -0
- package/build/Contracts/MiddlewareContract.js +9 -0
- package/build/Contracts/TerminatorContract.d.ts +15 -0
- package/build/Contracts/TerminatorContract.js +9 -0
- package/build/Decorators/Controller.d.ts +14 -0
- package/build/Decorators/Controller.js +28 -0
- package/build/Decorators/Interceptor.d.ts +14 -0
- package/build/Decorators/Interceptor.js +37 -0
- package/build/Decorators/Middleware.d.ts +14 -0
- package/build/Decorators/Middleware.js +37 -0
- package/build/Decorators/Terminator.d.ts +14 -0
- package/build/Decorators/Terminator.js +37 -0
- package/build/Exceptions/BadGatewayException.d.ts +20 -0
- package/build/Exceptions/BadGatewayException.js +22 -0
- package/build/Exceptions/BadRequestException.d.ts +20 -0
- package/build/Exceptions/BadRequestException.js +22 -0
- package/build/Exceptions/ForbiddenException.d.ts +20 -0
- package/build/Exceptions/ForbiddenException.js +22 -0
- package/build/Exceptions/HttpException.d.ts +20 -0
- package/build/Exceptions/HttpException.js +27 -0
- package/build/Exceptions/InternalServerException.d.ts +20 -0
- package/build/Exceptions/InternalServerException.js +22 -0
- package/build/Exceptions/MethodNotAllowedException.d.ts +20 -0
- package/build/Exceptions/MethodNotAllowedException.js +22 -0
- package/build/Exceptions/NotAcceptableException.d.ts +20 -0
- package/build/Exceptions/NotAcceptableException.js +22 -0
- package/build/Exceptions/NotFoundException.d.ts +20 -0
- package/build/Exceptions/NotFoundException.js +22 -0
- package/build/Exceptions/NotImplementedException.d.ts +20 -0
- package/build/Exceptions/NotImplementedException.js +22 -0
- package/build/Exceptions/PayloadTooLargeException.d.ts +20 -0
- package/build/Exceptions/PayloadTooLargeException.js +22 -0
- package/build/Exceptions/RequestTimeoutException.d.ts +20 -0
- package/build/Exceptions/RequestTimeoutException.js +22 -0
- package/build/Exceptions/ServiceUnavailableException.d.ts +20 -0
- package/build/Exceptions/ServiceUnavailableException.js +22 -0
- package/build/Exceptions/UnauthorizedException.d.ts +20 -0
- package/build/Exceptions/UnauthorizedException.js +22 -0
- package/build/Exceptions/UndefinedMethodException.d.ts +12 -0
- package/build/Exceptions/UndefinedMethodException.js +19 -0
- package/build/Exceptions/UnprocessableEntityException.d.ts +20 -0
- package/build/Exceptions/UnprocessableEntityException.js +22 -0
- package/build/Facades/Route.d.ts +10 -0
- package/{src → build}/Facades/Route.js +2 -7
- package/build/Facades/Server.d.ts +10 -0
- package/{src → build}/Facades/Server.js +2 -7
- package/build/Handlers/FastifyHandler.d.ts +41 -0
- package/build/Handlers/FastifyHandler.js +116 -0
- package/build/Handlers/HttpExceptionHandler.d.ts +31 -0
- package/build/Handlers/HttpExceptionHandler.js +82 -0
- package/build/Kernels/HttpKernel.d.ts +73 -0
- package/build/Kernels/HttpKernel.js +221 -0
- package/build/Providers/HttpRouteProvider.d.ts +12 -0
- package/build/Providers/HttpRouteProvider.js +15 -0
- package/build/Providers/HttpServerProvider.d.ts +13 -0
- package/build/Providers/HttpServerProvider.js +25 -0
- package/build/Router/Route.d.ts +263 -0
- package/build/Router/Route.js +447 -0
- package/build/Router/RouteGroup.d.ts +96 -0
- package/build/Router/RouteGroup.js +123 -0
- package/build/Router/RouteResource.d.ts +108 -0
- package/build/Router/RouteResource.js +158 -0
- package/build/Router/Router.d.ts +103 -0
- package/build/Router/Router.js +188 -0
- package/build/Server/ServerImpl.d.ts +129 -0
- package/build/Server/ServerImpl.js +213 -0
- package/build/Types/Contexts/Context.d.ts +20 -0
- package/build/Types/Contexts/Context.js +9 -0
- package/build/Types/Contexts/ErrorContext.d.ts +21 -0
- package/build/Types/Contexts/ErrorContext.js +9 -0
- package/build/Types/Contexts/InterceptContext.d.ts +20 -0
- package/build/Types/Contexts/InterceptContext.js +9 -0
- package/build/Types/Contexts/TerminateContext.d.ts +21 -0
- package/build/Types/Contexts/TerminateContext.js +9 -0
- package/build/Types/Controllers/ControllerOptions.d.ts +25 -0
- package/build/Types/Controllers/ControllerOptions.js +9 -0
- package/build/Types/Middlewares/InterceptorRouteType.d.ts +11 -0
- package/build/Types/Middlewares/InterceptorRouteType.js +9 -0
- package/build/Types/Middlewares/MiddlewareHandler.d.ts +20 -0
- package/build/Types/Middlewares/MiddlewareHandler.js +9 -0
- package/build/Types/Middlewares/MiddlewareOptions.d.ts +40 -0
- package/build/Types/Middlewares/MiddlewareOptions.js +9 -0
- package/build/Types/Middlewares/MiddlewareRouteType.d.ts +11 -0
- package/build/Types/Middlewares/MiddlewareRouteType.js +9 -0
- package/build/Types/Middlewares/TerminatorRouteType.d.ts +11 -0
- package/build/Types/Middlewares/TerminatorRouteType.js +9 -0
- package/build/Types/Router/RouteHandler.d.ts +10 -0
- package/build/Types/Router/RouteHandler.js +9 -0
- package/build/Types/Router/RouteJSON.d.ts +21 -0
- package/build/Types/Router/RouteJSON.js +9 -0
- package/build/Types/Router/RouteResourceTypes.d.ts +9 -0
- package/build/Types/Router/RouteResourceTypes.js +9 -0
- package/build/index.d.ts +70 -0
- package/build/index.js +48 -0
- package/package.json +159 -77
- package/templates/controller.edge +8 -36
- package/templates/interceptor.edge +8 -0
- package/templates/middleware.edge +4 -36
- package/templates/terminator.edge +6 -0
- package/src/Commands/Make/Controller.js +0 -64
- package/src/Commands/Make/Middleware.js +0 -80
- package/src/Commands/Route/List.js +0 -107
- package/src/Context/Request.js +0 -268
- package/src/Context/Response.js +0 -173
- package/src/Exceptions/BadGatewayException.js +0 -31
- package/src/Exceptions/BadRequestException.js +0 -31
- package/src/Exceptions/ForbiddenException.js +0 -31
- package/src/Exceptions/HttpException.js +0 -33
- package/src/Exceptions/InternalServerException.js +0 -31
- package/src/Exceptions/MethodNotAllowedException.js +0 -31
- package/src/Exceptions/NotAcceptableException.js +0 -31
- package/src/Exceptions/NotFoundException.js +0 -31
- package/src/Exceptions/NotImplementedException.js +0 -31
- package/src/Exceptions/PayloadTooLargeException.js +0 -31
- package/src/Exceptions/RequestTimeoutException.js +0 -31
- package/src/Exceptions/ServiceUnavailableException.js +0 -31
- package/src/Exceptions/UnauthorizedException.js +0 -31
- package/src/Exceptions/UndefinedMethodException.js +0 -30
- package/src/Exceptions/UnprocessableEntityException.js +0 -31
- package/src/Handlers/FastifyHandler.js +0 -148
- package/src/Handlers/HttpExceptionHandler.js +0 -88
- package/src/Helpers/HttpLoader.js +0 -38
- package/src/Kernels/HttpKernel.js +0 -199
- package/src/Providers/ControllerProvider.js +0 -29
- package/src/Providers/HttpRouteProvider.js +0 -24
- package/src/Providers/HttpServerProvider.js +0 -37
- package/src/Providers/MiddlewareProvider.js +0 -29
- package/src/Router/Route.js +0 -411
- package/src/Router/RouteGroup.js +0 -119
- package/src/Router/RouteResource.js +0 -247
- package/src/Router/Router.js +0 -313
- package/src/Utils/isMiddlewareContract.js +0 -17
- package/src/Utils/removeSlashes.js +0 -30
- package/src/index.d.ts +0 -1395
- package/src/index.js +0 -377
package/src/index.js
DELETED
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @athenna/http
|
|
3
|
-
*
|
|
4
|
-
* (c) João Lenon <lenon@athenna.io>
|
|
5
|
-
*
|
|
6
|
-
* For the full copyright and license information, please view the LICENSE
|
|
7
|
-
* file that was distributed with this source code.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import fastify from 'fastify'
|
|
11
|
-
|
|
12
|
-
import { Options } from '@athenna/common'
|
|
13
|
-
import { FastifyHandler } from '#src/Handlers/FastifyHandler'
|
|
14
|
-
|
|
15
|
-
export * from './Facades/Route.js'
|
|
16
|
-
export * from './Facades/Server.js'
|
|
17
|
-
export * from './Kernels/HttpKernel.js'
|
|
18
|
-
export * from './Handlers/HttpExceptionHandler.js'
|
|
19
|
-
|
|
20
|
-
export * from './Commands/Route/List.js'
|
|
21
|
-
export * from './Commands/Make/Controller.js'
|
|
22
|
-
export * from './Commands/Make/Middleware.js'
|
|
23
|
-
|
|
24
|
-
export * from './Helpers/HttpLoader.js'
|
|
25
|
-
|
|
26
|
-
export * from './Exceptions/BadGatewayException.js'
|
|
27
|
-
export * from './Exceptions/BadRequestException.js'
|
|
28
|
-
export * from './Exceptions/ForbiddenException.js'
|
|
29
|
-
export * from './Exceptions/HttpException.js'
|
|
30
|
-
export * from './Exceptions/InternalServerException.js'
|
|
31
|
-
export * from './Exceptions/MethodNotAllowedException.js'
|
|
32
|
-
export * from './Exceptions/NotAcceptableException.js'
|
|
33
|
-
export * from './Exceptions/NotFoundException.js'
|
|
34
|
-
export * from './Exceptions/NotImplementedException.js'
|
|
35
|
-
export * from './Exceptions/PayloadTooLargeException.js'
|
|
36
|
-
export * from './Exceptions/RequestTimeoutException.js'
|
|
37
|
-
export * from './Exceptions/ServiceUnavailableException.js'
|
|
38
|
-
export * from './Exceptions/UnauthorizedException.js'
|
|
39
|
-
export * from './Exceptions/UnprocessableEntityException.js'
|
|
40
|
-
|
|
41
|
-
export class Http {
|
|
42
|
-
/**
|
|
43
|
-
* Holds the fastify server instance.
|
|
44
|
-
*
|
|
45
|
-
* @type {import('fastify').FastifyInstance}
|
|
46
|
-
*/
|
|
47
|
-
#server
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Indicates if the http server is running or not.
|
|
51
|
-
*
|
|
52
|
-
* @type {boolean}
|
|
53
|
-
*/
|
|
54
|
-
#isListening
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Creates a new instance of Http class.
|
|
58
|
-
*
|
|
59
|
-
* @return {Http}
|
|
60
|
-
*/
|
|
61
|
-
constructor() {
|
|
62
|
-
this.#server = fastify()
|
|
63
|
-
this.#isListening = false
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Set the fastify error handler.
|
|
68
|
-
*
|
|
69
|
-
* @param {any} handler
|
|
70
|
-
* @return {Http}
|
|
71
|
-
*/
|
|
72
|
-
setErrorHandler(handler) {
|
|
73
|
-
const fastifyErrorHandler = FastifyHandler.createErrorHandler(handler)
|
|
74
|
-
|
|
75
|
-
this.#server.setErrorHandler(fastifyErrorHandler)
|
|
76
|
-
|
|
77
|
-
return this
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Register a new fastify plugin.
|
|
82
|
-
*
|
|
83
|
-
* @param {any} plugin
|
|
84
|
-
* @param {any} [options]
|
|
85
|
-
* @return {Promise<Http>}
|
|
86
|
-
*/
|
|
87
|
-
async register(plugin, options = {}) {
|
|
88
|
-
await this.#server.register(plugin, options)
|
|
89
|
-
|
|
90
|
-
return this
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Register the cors plugin to fastify server.
|
|
95
|
-
*
|
|
96
|
-
* @param {import('@fastify/cors').FastifyCorsOptions} [options]
|
|
97
|
-
* @return {Promise<Http>}
|
|
98
|
-
*/
|
|
99
|
-
async registerCors(options) {
|
|
100
|
-
return this.register(import('@fastify/cors'), options)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Register the rTracer plugin to fastify server.
|
|
105
|
-
*
|
|
106
|
-
* @param {import('cls-rtracer').IFastifyOptions} [options]
|
|
107
|
-
* @return {Promise<Http>}
|
|
108
|
-
*/
|
|
109
|
-
async registerTracer(options) {
|
|
110
|
-
const rTracer = await import('cls-rtracer')
|
|
111
|
-
|
|
112
|
-
return this.register(rTracer.fastifyPlugin, options)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Register the helmet plugin to fastify server.
|
|
117
|
-
*
|
|
118
|
-
* @param {import('@fastify/helmet').FastifyHelmetOptions} [options]
|
|
119
|
-
* @return {Promise<Http>}
|
|
120
|
-
*/
|
|
121
|
-
async registerHelmet(options) {
|
|
122
|
-
return this.register(import('@fastify/helmet'), options)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Register the swagger plugin to fastify server.
|
|
127
|
-
*
|
|
128
|
-
* @param {{
|
|
129
|
-
* ui: import('@fastify/swagger-ui').FastifySwaggerUiOptions,
|
|
130
|
-
* configurations: import('@fastify/swagger').SwaggerOptions
|
|
131
|
-
* }} [options]
|
|
132
|
-
* @return {Promise<Http>}
|
|
133
|
-
*/
|
|
134
|
-
async registerSwagger(options = {}) {
|
|
135
|
-
await this.register(import('@fastify/swagger'), options.configurations)
|
|
136
|
-
|
|
137
|
-
return this.register(import('@fastify/swagger-ui'), options.ui)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Register the rate limit plugin to fastify server.
|
|
142
|
-
*
|
|
143
|
-
* @param {import('@fastify/rate-limit').RateLimitOptions} [options]
|
|
144
|
-
* @return {Promise<Http>}
|
|
145
|
-
*/
|
|
146
|
-
async registerRateLimit(options) {
|
|
147
|
-
return this.register(import('@fastify/rate-limit'), options)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Get the fastify server instance.
|
|
152
|
-
*
|
|
153
|
-
* @return {import('fastify').FastifyInstance}
|
|
154
|
-
*/
|
|
155
|
-
getFastify() {
|
|
156
|
-
return this.#server
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Print all routes registered.
|
|
161
|
-
*
|
|
162
|
-
* @param {import('fastify').PrintRoutesOptions} [options]
|
|
163
|
-
* @return {string}
|
|
164
|
-
*/
|
|
165
|
-
getRoutes(options) {
|
|
166
|
-
return this.#server.printRoutes(options)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Get the server port where http is being running.
|
|
171
|
-
*
|
|
172
|
-
* @return {number}
|
|
173
|
-
*/
|
|
174
|
-
getPort() {
|
|
175
|
-
return this.#server.server.address().port
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Get the server http version.
|
|
180
|
-
*
|
|
181
|
-
* @return {string}
|
|
182
|
-
*/
|
|
183
|
-
getVersion() {
|
|
184
|
-
return this.#server.version
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Print all routes registered.
|
|
189
|
-
*
|
|
190
|
-
* @param {any} handler
|
|
191
|
-
* @param {'handle'|'intercept'|'terminate'} type
|
|
192
|
-
* @return void
|
|
193
|
-
*/
|
|
194
|
-
use(handler, type = 'handle') {
|
|
195
|
-
let hookName = 'preHandler'
|
|
196
|
-
let handlerType = 'createDoneHandler'
|
|
197
|
-
|
|
198
|
-
switch (type) {
|
|
199
|
-
case 'intercept':
|
|
200
|
-
hookName = 'onSend'
|
|
201
|
-
handlerType = 'createOnSendHandler'
|
|
202
|
-
break
|
|
203
|
-
case 'terminate':
|
|
204
|
-
hookName = 'onResponse'
|
|
205
|
-
handlerType = 'createOnResponseHandler'
|
|
206
|
-
break
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
this.#server.addHook(hookName, FastifyHandler[handlerType](handler))
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Return a request handler to make internal requests to the Http server.
|
|
214
|
-
*
|
|
215
|
-
* @param {import('fastify').InjectOptions|string} [options]
|
|
216
|
-
* @return {import('light-my-request').Chain,Promise<import('light-my-request').Response>}
|
|
217
|
-
*/
|
|
218
|
-
request(options) {
|
|
219
|
-
const server = this.getFastify()
|
|
220
|
-
|
|
221
|
-
if (!options) {
|
|
222
|
-
return server.inject()
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return server.inject(options)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Boot the http server to start listening on port and host defined.
|
|
230
|
-
*
|
|
231
|
-
* @param {string|number} [port]
|
|
232
|
-
* @param {string} [host]
|
|
233
|
-
* @return {Promise<string>}
|
|
234
|
-
*/
|
|
235
|
-
async listen(port = 0, host = '0.0.0.0') {
|
|
236
|
-
this.#isListening = true
|
|
237
|
-
|
|
238
|
-
return this.#server.listen({ port, host })
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Close the http server.
|
|
243
|
-
*
|
|
244
|
-
* @return {Promise<void>}
|
|
245
|
-
*/
|
|
246
|
-
async close() {
|
|
247
|
-
if (!this.#isListening) {
|
|
248
|
-
return
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
return this.#server.close()
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Add a new route to the http server.
|
|
256
|
-
*
|
|
257
|
-
* @param {string} url
|
|
258
|
-
* @param {string[]} methods
|
|
259
|
-
* @param {any} handler
|
|
260
|
-
* @param {any} [middlewares]
|
|
261
|
-
* @param {import('fastify').RouteOptions} [otherOptions]
|
|
262
|
-
* @return {void}
|
|
263
|
-
*/
|
|
264
|
-
route(url, methods, handler, middlewares, otherOptions = {}) {
|
|
265
|
-
const { handlers, terminators, interceptors } = Options.create(
|
|
266
|
-
middlewares,
|
|
267
|
-
{
|
|
268
|
-
handlers: [],
|
|
269
|
-
terminators: [],
|
|
270
|
-
interceptors: [],
|
|
271
|
-
},
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
this.#server.route({
|
|
275
|
-
url,
|
|
276
|
-
method: methods,
|
|
277
|
-
onResponse: terminators.map(m =>
|
|
278
|
-
FastifyHandler.createOnResponseHandler(m),
|
|
279
|
-
),
|
|
280
|
-
handler: FastifyHandler.createRequestHandler(handler),
|
|
281
|
-
preHandler: handlers.map(m => FastifyHandler.createDoneHandler(m)),
|
|
282
|
-
onSend: interceptors.map(m => FastifyHandler.createOnSendHandler(m)),
|
|
283
|
-
...otherOptions,
|
|
284
|
-
})
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Add a new GET route to the http server.
|
|
289
|
-
*
|
|
290
|
-
* @param {string} url
|
|
291
|
-
* @param {any} handler
|
|
292
|
-
* @param {any} [middlewares]
|
|
293
|
-
* @param {import('fastify').RouteOptions} [otherOptions]
|
|
294
|
-
* @return {void}
|
|
295
|
-
*/
|
|
296
|
-
get(url, handler, middlewares, otherOptions) {
|
|
297
|
-
this.route(url, ['GET'], handler, middlewares, otherOptions)
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Add a new HEAD route to the http server.
|
|
302
|
-
*
|
|
303
|
-
* @param {string} url
|
|
304
|
-
* @param {any} handler
|
|
305
|
-
* @param {any} [middlewares]
|
|
306
|
-
* @param {import('fastify').RouteOptions} [otherOptions]
|
|
307
|
-
* @return {void}
|
|
308
|
-
*/
|
|
309
|
-
head(url, handler, middlewares, otherOptions) {
|
|
310
|
-
this.route(url, ['HEAD'], handler, middlewares, otherOptions)
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Add a new POST route to the http server.
|
|
315
|
-
*
|
|
316
|
-
* @param {string} url
|
|
317
|
-
* @param {any} handler
|
|
318
|
-
* @param {any} [middlewares]
|
|
319
|
-
* @param {import('fastify').RouteOptions} [otherOptions]
|
|
320
|
-
* @return {void}
|
|
321
|
-
*/
|
|
322
|
-
post(url, handler, middlewares, otherOptions) {
|
|
323
|
-
this.route(url, ['POST'], handler, middlewares, otherOptions)
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Add a new PUT route to the http server.
|
|
328
|
-
*
|
|
329
|
-
* @param {string} url
|
|
330
|
-
* @param {any} handler
|
|
331
|
-
* @param {any} [middlewares]
|
|
332
|
-
* @param {import('fastify').RouteOptions} [otherOptions]
|
|
333
|
-
* @return {void}
|
|
334
|
-
*/
|
|
335
|
-
put(url, handler, middlewares, otherOptions) {
|
|
336
|
-
this.route(url, ['PUT'], handler, middlewares, otherOptions)
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Add a new PATCH route to the http server.
|
|
341
|
-
*
|
|
342
|
-
* @param {string} url
|
|
343
|
-
* @param {any} handler
|
|
344
|
-
* @param {any} [middlewares]
|
|
345
|
-
* @param {import('fastify').RouteOptions} [otherOptions]
|
|
346
|
-
* @return {void}
|
|
347
|
-
*/
|
|
348
|
-
patch(url, handler, middlewares, otherOptions) {
|
|
349
|
-
this.route(url, ['PATCH'], handler, middlewares, otherOptions)
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Add a new DELETE route to the http server.
|
|
354
|
-
*
|
|
355
|
-
* @param {string} url
|
|
356
|
-
* @param {any} handler
|
|
357
|
-
* @param {any} [middlewares]
|
|
358
|
-
* @param {import('fastify').RouteOptions} [otherOptions]
|
|
359
|
-
* @return {void}
|
|
360
|
-
*/
|
|
361
|
-
delete(url, handler, middlewares, otherOptions) {
|
|
362
|
-
this.route(url, ['DELETE'], handler, middlewares, otherOptions)
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Add a new OPTIONS route to the http server.
|
|
367
|
-
*
|
|
368
|
-
* @param {string} url
|
|
369
|
-
* @param {any} handler
|
|
370
|
-
* @param {any} [middlewares]
|
|
371
|
-
* @param {import('fastify').RouteOptions} [otherOptions]
|
|
372
|
-
* @return {void}
|
|
373
|
-
*/
|
|
374
|
-
options(url, handler, middlewares, otherOptions) {
|
|
375
|
-
this.route(url, ['OPTIONS'], handler, middlewares, otherOptions)
|
|
376
|
-
}
|
|
377
|
-
}
|