@athenna/http 5.23.0 → 5.25.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/package.json +18 -18
- package/src/context/Request.d.ts +2 -1
- package/src/context/Request.js +3 -2
- package/src/context/Response.d.ts +2 -1
- package/src/context/Response.js +3 -1
- package/src/kernels/HttpKernel.js +5 -5
- package/src/router/Route.d.ts +2 -1
- package/src/router/Route.js +3 -2
- package/src/router/RouteGroup.d.ts +2 -1
- package/src/router/RouteGroup.js +3 -1
- package/src/router/RouteResource.d.ts +2 -1
- package/src/router/RouteResource.js +3 -2
- package/src/router/Router.d.ts +2 -1
- package/src/router/Router.js +3 -2
- package/src/server/ServerImpl.d.ts +3 -2
- package/src/server/ServerImpl.js +3 -2
- package/src/testing/plugins/request/TestRequest.d.ts +2 -1
- package/src/testing/plugins/request/TestRequest.js +3 -1
- package/src/testing/plugins/request/TestResponse.d.ts +2 -1
- package/src/testing/plugins/request/TestResponse.js +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@athenna/http",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.25.0",
|
|
4
4
|
"description": "The Athenna Http server. Built on top of fastify.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "João Lenon <lenon@athenna.io>",
|
|
@@ -74,23 +74,23 @@
|
|
|
74
74
|
"#tests": "./tests/index.js"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@athenna/artisan": "^5.
|
|
78
|
-
"@athenna/common": "^5.
|
|
79
|
-
"@athenna/config": "^5.
|
|
80
|
-
"@athenna/ioc": "^5.
|
|
81
|
-
"@athenna/logger": "^5.
|
|
82
|
-
"@athenna/test": "^5.
|
|
77
|
+
"@athenna/artisan": "^5.6.0",
|
|
78
|
+
"@athenna/common": "^5.7.0",
|
|
79
|
+
"@athenna/config": "^5.3.0",
|
|
80
|
+
"@athenna/ioc": "^5.1.0",
|
|
81
|
+
"@athenna/logger": "^5.3.0",
|
|
82
|
+
"@athenna/test": "^5.3.0",
|
|
83
83
|
"@athenna/tsconfig": "^5.0.0",
|
|
84
|
-
"@athenna/view": "^5.
|
|
85
|
-
"@athenna/vite": "^5.
|
|
86
|
-
"@fastify/cors": "^10.0.
|
|
87
|
-
"@fastify/helmet": "^13.0.
|
|
88
|
-
"@fastify/rate-limit": "^10.2.
|
|
89
|
-
"@fastify/static": "^8.0.
|
|
90
|
-
"@fastify/swagger": "^9.4.
|
|
91
|
-
"@fastify/swagger-ui": "^5.2.
|
|
92
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
93
|
-
"@typescript-eslint/parser": "^
|
|
84
|
+
"@athenna/view": "^5.3.0",
|
|
85
|
+
"@athenna/vite": "^5.13.0",
|
|
86
|
+
"@fastify/cors": "^10.0.2",
|
|
87
|
+
"@fastify/helmet": "^13.0.1",
|
|
88
|
+
"@fastify/rate-limit": "^10.2.2",
|
|
89
|
+
"@fastify/static": "^8.0.4",
|
|
90
|
+
"@fastify/swagger": "^9.4.2",
|
|
91
|
+
"@fastify/swagger-ui": "^5.2.1",
|
|
92
|
+
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
|
93
|
+
"@typescript-eslint/parser": "^8.21.0",
|
|
94
94
|
"autocannon": "^7.15.0",
|
|
95
95
|
"commitizen": "^4.3.1",
|
|
96
96
|
"cz-conventional-changelog": "^3.3.0",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"lint-staged": "^12.5.0",
|
|
107
107
|
"ora": "^8.1.1",
|
|
108
108
|
"prettier": "^2.8.8",
|
|
109
|
-
"vite": "^6.0.
|
|
109
|
+
"vite": "^6.0.11",
|
|
110
110
|
"vite-plugin-restart": "^0.4.2"
|
|
111
111
|
},
|
|
112
112
|
"c8": {
|
package/src/context/Request.d.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import type { FastifyRequest } from 'fastify';
|
|
10
|
-
|
|
10
|
+
import { Macroable } from '@athenna/common';
|
|
11
|
+
export declare class Request extends Macroable {
|
|
11
12
|
/**
|
|
12
13
|
* The fastify request object.
|
|
13
14
|
*/
|
package/src/context/Request.js
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Is, Json } from '@athenna/common';
|
|
10
|
-
export class Request {
|
|
9
|
+
import { Is, Json, Macroable } from '@athenna/common';
|
|
10
|
+
export class Request extends Macroable {
|
|
11
11
|
constructor(request) {
|
|
12
|
+
super();
|
|
12
13
|
this.request = request;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
+
import { Macroable } from '@athenna/common';
|
|
9
10
|
import type { FastifyReply } from 'fastify';
|
|
10
11
|
import type { SendOptions } from '@fastify/static';
|
|
11
12
|
import type { Request } from '#src/context/Request';
|
|
12
13
|
import type { FastifyHelmetOptions } from '@fastify/helmet';
|
|
13
|
-
export declare class Response {
|
|
14
|
+
export declare class Response extends Macroable {
|
|
14
15
|
/**
|
|
15
16
|
* The fastify response object.
|
|
16
17
|
*/
|
package/src/context/Response.js
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { View } from '@athenna/view';
|
|
10
|
-
|
|
10
|
+
import { Macroable } from '@athenna/common';
|
|
11
|
+
export class Response extends Macroable {
|
|
11
12
|
constructor(response, request) {
|
|
13
|
+
super();
|
|
12
14
|
this.response = response;
|
|
13
15
|
this.request = request;
|
|
14
16
|
}
|
|
@@ -13,7 +13,7 @@ import { Log } from '@athenna/logger';
|
|
|
13
13
|
import { Config } from '@athenna/config';
|
|
14
14
|
import { sep, isAbsolute, resolve } from 'node:path';
|
|
15
15
|
import { Annotation } from '@athenna/ioc';
|
|
16
|
-
import { File, Path,
|
|
16
|
+
import { File, Path, Module, String } from '@athenna/common';
|
|
17
17
|
import { HttpExceptionHandler } from '#src/handlers/HttpExceptionHandler';
|
|
18
18
|
const corsPlugin = await Module.safeImport('@fastify/cors');
|
|
19
19
|
const helmetPlugin = await Module.safeImport('@fastify/helmet');
|
|
@@ -163,7 +163,7 @@ export class HttpKernel {
|
|
|
163
163
|
*/
|
|
164
164
|
async registerControllers() {
|
|
165
165
|
const controllers = Config.get('rc.controllers', []);
|
|
166
|
-
await
|
|
166
|
+
await controllers.athenna.concurrently(async (path) => {
|
|
167
167
|
const Controller = await Module.resolve(path, this.getMeta());
|
|
168
168
|
if (Annotation.isAnnotated(Controller)) {
|
|
169
169
|
this.registerUsingMeta(Controller);
|
|
@@ -179,7 +179,7 @@ export class HttpKernel {
|
|
|
179
179
|
*/
|
|
180
180
|
async registerMiddlewares() {
|
|
181
181
|
const middlewares = Config.get('rc.middlewares', []);
|
|
182
|
-
await
|
|
182
|
+
await middlewares.athenna.concurrently(async (path) => {
|
|
183
183
|
const Middleware = await Module.resolve(path, this.getMeta());
|
|
184
184
|
if (Annotation.isAnnotated(Middleware)) {
|
|
185
185
|
this.registerUsingMeta(Middleware);
|
|
@@ -198,7 +198,7 @@ export class HttpKernel {
|
|
|
198
198
|
*/
|
|
199
199
|
async registerNamedMiddlewares() {
|
|
200
200
|
const namedMiddlewares = Config.get('rc.namedMiddlewares', {});
|
|
201
|
-
await
|
|
201
|
+
await Object.keys(namedMiddlewares).athenna.concurrently(async (key) => {
|
|
202
202
|
const Middleware = await Module.resolve(namedMiddlewares[key], this.getMeta());
|
|
203
203
|
if (Annotation.isAnnotated(Middleware)) {
|
|
204
204
|
this.registerUsingMeta(Middleware);
|
|
@@ -214,7 +214,7 @@ export class HttpKernel {
|
|
|
214
214
|
*/
|
|
215
215
|
async registerGlobalMiddlewares() {
|
|
216
216
|
const globalMiddlewares = Config.get('rc.globalMiddlewares', []);
|
|
217
|
-
await
|
|
217
|
+
await globalMiddlewares.athenna.concurrently(async (path) => {
|
|
218
218
|
const Middleware = await Module.resolve(path, this.getMeta());
|
|
219
219
|
if (Annotation.isAnnotated(Middleware)) {
|
|
220
220
|
this.registerUsingMeta(Middleware);
|
package/src/router/Route.d.ts
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { RouteJson, RouteHandler, RequestHandler, MiddlewareRecord, MiddlewareRouteType, TerminatorRouteType, InterceptorRouteType } from '#src/types';
|
|
10
10
|
import type { HTTPMethods, FastifySchema, RouteOptions } from 'fastify';
|
|
11
|
-
|
|
11
|
+
import { Macroable } from '@athenna/common';
|
|
12
|
+
export declare class Route extends Macroable {
|
|
12
13
|
/**
|
|
13
14
|
* Holds all the route implementations to be registered in the Server.
|
|
14
15
|
*/
|
package/src/router/Route.js
CHANGED
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Is, Options, Route as RouteHelper } from '@athenna/common';
|
|
9
|
+
import { Is, Options, Macroable, Route as RouteHelper } from '@athenna/common';
|
|
10
10
|
import { UndefinedMethodException } from '#src/exceptions/UndefinedMethodException';
|
|
11
11
|
import { NotFoundValidatorException } from '#src/exceptions/NotFoundValidatorException';
|
|
12
12
|
import { NotFoundMiddlewareException } from '#src/exceptions/NotFoundMiddlewareException';
|
|
13
|
-
export class Route {
|
|
13
|
+
export class Route extends Macroable {
|
|
14
14
|
constructor(url, methods, handler) {
|
|
15
|
+
super();
|
|
15
16
|
this.route = {
|
|
16
17
|
url,
|
|
17
18
|
methods,
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { MiddlewareRouteType, TerminatorRouteType, InterceptorRouteType } from '#src/types';
|
|
10
10
|
import { Route } from '#src/router/Route';
|
|
11
|
+
import { Macroable } from '@athenna/common';
|
|
11
12
|
import { RouteResource } from '#src/router/RouteResource';
|
|
12
|
-
export declare class RouteGroup {
|
|
13
|
+
export declare class RouteGroup extends Macroable {
|
|
13
14
|
/**
|
|
14
15
|
* All routes registered in the group.
|
|
15
16
|
*/
|
package/src/router/RouteGroup.js
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Route } from '#src/router/Route';
|
|
10
|
+
import { Macroable } from '@athenna/common';
|
|
10
11
|
import { RouteResource } from '#src/router/RouteResource';
|
|
11
|
-
export class RouteGroup {
|
|
12
|
+
export class RouteGroup extends Macroable {
|
|
12
13
|
constructor(routes) {
|
|
14
|
+
super();
|
|
13
15
|
this.routes = routes;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { RouteResourceTypes, TerminatorRouteType, MiddlewareRouteType, InterceptorRouteType } from '#src/types';
|
|
10
10
|
import { Route } from '#src/router/Route';
|
|
11
|
-
|
|
11
|
+
import { Macroable } from '@athenna/common';
|
|
12
|
+
export declare class RouteResource extends Macroable {
|
|
12
13
|
/**
|
|
13
14
|
* All routes registered in the resource.
|
|
14
15
|
*/
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Route } from '#src/router/Route';
|
|
10
|
-
import { Is, String } from '@athenna/common';
|
|
11
|
-
export class RouteResource {
|
|
10
|
+
import { Is, String, Macroable } from '@athenna/common';
|
|
11
|
+
export class RouteResource extends Macroable {
|
|
12
12
|
constructor(resource, controller) {
|
|
13
|
+
super();
|
|
13
14
|
/**
|
|
14
15
|
* All routes registered in the resource.
|
|
15
16
|
*/
|
package/src/router/Router.d.ts
CHANGED
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Route } from '#src/router/Route';
|
|
10
|
+
import { Macroable } from '@athenna/common';
|
|
10
11
|
import { RouteGroup } from '#src/router/RouteGroup';
|
|
11
12
|
import { RouteResource } from '#src/router/RouteResource';
|
|
12
13
|
import type { RouteJson, RequestHandler, RouteHandler } from '#src/types';
|
|
13
14
|
import type { HTTPMethods, FastifyInstance, RouteOptions } from 'fastify';
|
|
14
|
-
export declare class Router {
|
|
15
|
+
export declare class Router extends Macroable {
|
|
15
16
|
/**
|
|
16
17
|
* All routes registered.
|
|
17
18
|
*/
|
package/src/router/Router.js
CHANGED
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
import { Is } from '@athenna/common';
|
|
10
9
|
import { Route } from '#src/router/Route';
|
|
11
10
|
import { Server } from '#src/facades/Server';
|
|
11
|
+
import { Is, Macroable } from '@athenna/common';
|
|
12
12
|
import { RouteGroup } from '#src/router/RouteGroup';
|
|
13
13
|
import { RouteResource } from '#src/router/RouteResource';
|
|
14
14
|
import { UndefinedMethodException } from '#src/exceptions/UndefinedMethodException';
|
|
15
|
-
export class Router {
|
|
15
|
+
export class Router extends Macroable {
|
|
16
16
|
constructor() {
|
|
17
|
+
super(...arguments);
|
|
17
18
|
/**
|
|
18
19
|
* All routes registered.
|
|
19
20
|
*/
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { InjectOptions, FastifyInstance, PrintRoutesOptions, FastifyListenOptions, FastifyServerOptions, LightMyRequestChain, LightMyRequestResponse } from 'fastify';
|
|
10
10
|
import type { RouteJson, ErrorHandler, RequestHandler, InterceptHandler, TerminateHandler, SwaggerDocument } from '#src/types';
|
|
11
|
-
import type { FastifyVite } from '@athenna/vite';
|
|
12
11
|
import type { AddressInfo } from 'node:net';
|
|
13
|
-
|
|
12
|
+
import type { FastifyVite } from '@athenna/vite';
|
|
13
|
+
import { Macroable } from '@athenna/common';
|
|
14
|
+
export declare class ServerImpl extends Macroable {
|
|
14
15
|
/**
|
|
15
16
|
* Holds the fastify server instance.
|
|
16
17
|
*/
|
package/src/server/ServerImpl.js
CHANGED
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import fastify from 'fastify';
|
|
10
|
-
import { Options } from '@athenna/common';
|
|
10
|
+
import { Options, Macroable } from '@athenna/common';
|
|
11
11
|
import { FastifyHandler } from '#src/handlers/FastifyHandler';
|
|
12
|
-
export class ServerImpl {
|
|
12
|
+
export class ServerImpl extends Macroable {
|
|
13
13
|
constructor(options) {
|
|
14
|
+
super();
|
|
14
15
|
this.fastify = fastify.fastify({ ...options, exposeHeadRoutes: false });
|
|
15
16
|
this.isListening = false;
|
|
16
17
|
this.fastify.decorateReply('body', null);
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Assert } from '@japa/assert';
|
|
10
|
+
import { Macroable } from '@athenna/common';
|
|
10
11
|
import type { InjectOptions } from '#src/types';
|
|
11
12
|
import { TestResponse } from '#src/testing/plugins/request/TestResponse';
|
|
12
|
-
export declare class TestRequest {
|
|
13
|
+
export declare class TestRequest extends Macroable {
|
|
13
14
|
/**
|
|
14
15
|
* Japa assert class instance.
|
|
15
16
|
*/
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Server } from '#src';
|
|
10
10
|
import { Assert } from '@japa/assert';
|
|
11
|
+
import { Macroable } from '@athenna/common';
|
|
11
12
|
import { TestResponse } from '#src/testing/plugins/request/TestResponse';
|
|
12
|
-
export class TestRequest {
|
|
13
|
+
export class TestRequest extends Macroable {
|
|
13
14
|
constructor() {
|
|
15
|
+
super(...arguments);
|
|
14
16
|
/**
|
|
15
17
|
* Japa assert class instance.
|
|
16
18
|
*/
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Assert } from '@japa/assert';
|
|
10
|
+
import { Macroable } from '@athenna/common';
|
|
10
11
|
import type { Response } from 'light-my-request';
|
|
11
|
-
export declare class TestResponse {
|
|
12
|
+
export declare class TestResponse extends Macroable {
|
|
12
13
|
/**
|
|
13
14
|
* Japa assert class instance.
|
|
14
15
|
*/
|
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Assert } from '@japa/assert';
|
|
10
|
-
|
|
10
|
+
import { Macroable } from '@athenna/common';
|
|
11
|
+
export class TestResponse extends Macroable {
|
|
11
12
|
constructor(assert, response) {
|
|
13
|
+
super();
|
|
12
14
|
this.assert = assert;
|
|
13
15
|
this.response = response;
|
|
14
16
|
}
|