UNPKG

@athenna/http

Version:

The Athenna Http server. Built on top of fastify.

118 lines (117 loc) 2.83 kB
/** * @athenna/http * * (c) João Lenon <lenon@athenna.io> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import type { MiddlewareRouteType, TerminatorRouteType, InterceptorRouteType } from '#src/types'; import { Route } from '#src/router/Route'; import { Macroable } from '@athenna/common'; import { RouteResource } from '#src/router/RouteResource'; export declare class RouteGroup extends Macroable { /** * All routes registered in the group. */ routes: (Route | RouteGroup | RouteResource)[]; constructor(routes: (Route | RouteGroup | RouteResource)[]); /** * Define prefix for all the routes in the group. * * @example * ```ts * Route.group(() => { * * }).prefix('/api/v1') * ``` */ prefix(prefix: string): RouteGroup; /** * Define a name for all the routes in the group. * * @example * ```ts * Route.group(() => { * * }).name('users') * ``` */ name(name: string): RouteGroup; /** * Add a validator to all routes in the group. * * @example * ```ts * Route.group(() => { * * }).validator('auth') * ``` */ validator(validator: MiddlewareRouteType): RouteGroup; /** * Add a middleware to all routes in the group. * * @example * ```ts * Route.group(() => { * * }).middleware('auth') * ``` */ middleware(middleware: MiddlewareRouteType): RouteGroup; /** * Add an interceptor to all routes in the group. * * @example * ```ts * Route.group(() => { * * }).interceptor('response') * ``` */ interceptor(interceptor: InterceptorRouteType): RouteGroup; /** * Add a terminator to all routes in the group. * * @example * ```ts * Route.group(() => { * * }).terminator('log') * ``` */ terminator(terminator: TerminatorRouteType): RouteGroup; /** * Set up helmet options for route group. * * @example * ```ts * Route.group(() => { * * }).helmet({ * dnsPrefetchControl: { allow: true } * }) * ``` */ helmet(options: Omit<import('@fastify/helmet').FastifyHelmetOptions, 'global'>): RouteGroup; /** * Set up rate limit options for route group method. * * @example * ```ts * Route.group(() => { * * }).rateLimit({ * max: 3, * timeWindow: '1 minute' * }) * ``` */ rateLimit(options: import('@fastify/rate-limit').RateLimitOptions): RouteGroup; /** * Invokes a given method with params on the route instance or route * resource instance. */ private invoke; }