@athenna/http 1.0.2 → 1.0.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athenna/http",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
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>",
@@ -158,7 +158,7 @@
158
158
  }
159
159
  },
160
160
  "dependencies": {
161
- "@athenna/config": "1.0.1",
161
+ "@athenna/config": "1.0.5",
162
162
  "@athenna/ioc": "1.0.6",
163
163
  "@secjs/utils": "1.8.0",
164
164
  "fastify": "3.27.4",
@@ -8,5 +8,5 @@
8
8
  */
9
9
  import { ContextContract } from './ContextContract';
10
10
  export interface HandlerContract {
11
- (ctx?: ContextContract): Promise<any> | any;
11
+ (ctx: ContextContract): Promise<any> | any;
12
12
  }
@@ -8,5 +8,5 @@
8
8
  */
9
9
  import { HandleContextContract } from './HandleContextContract';
10
10
  export interface HandleHandlerContract {
11
- (ctx?: HandleContextContract): Promise<any> | any;
11
+ (ctx: HandleContextContract): Promise<any> | any;
12
12
  }
@@ -8,5 +8,5 @@
8
8
  */
9
9
  import { InterceptContextContract } from './InterceptContextContract';
10
10
  export interface InterceptHandlerContract {
11
- (ctx?: InterceptContextContract): Promise<any> | any;
11
+ (ctx: InterceptContextContract): Promise<any> | any;
12
12
  }
@@ -8,5 +8,5 @@
8
8
  */
9
9
  import { TerminateContextContract } from './TerminateContextContract';
10
10
  export interface TerminateHandlerContract {
11
- (ctx?: TerminateContextContract): Promise<any> | any;
11
+ (ctx: TerminateContextContract): Promise<any> | any;
12
12
  }
package/src/Http.js CHANGED
@@ -14,11 +14,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.Http = void 0;
15
15
  const fastify_1 = __importDefault(require("fastify"));
16
16
  const FastifyHandler_1 = require("./Utils/FastifyHandler");
17
- const defaultErrorHandler_1 = require("./Utils/defaultErrorHandler");
18
17
  class Http {
19
18
  constructor() {
20
19
  this.server = fastify_1.default();
21
- this.setErrorHandler(defaultErrorHandler_1.defaultErrorHandler);
22
20
  }
23
21
  setErrorHandler(handler) {
24
22
  const fastifyErrorHandler = FastifyHandler_1.FastifyHandler.createErrorHandler(handler);
@@ -1,10 +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
- import { ErrorContextContract } from '../Contracts/Context/Error/ErrorContextContract';
10
- export declare function defaultErrorHandler({ error, request, response, }: ErrorContextContract): void;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- /**
3
- * @athenna/http
4
- *
5
- * (c) João Lenon <lenon@athenna.io>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.defaultErrorHandler = void 0;
12
- const utils_1 = require("@secjs/utils");
13
- function defaultErrorHandler({ error, request, response, }) {
14
- const code = error.code || error.name;
15
- const statusCode = error.statusCode || error.status || 500;
16
- const body = {
17
- code: utils_1.String.toSnakeCase(code).toUpperCase(),
18
- path: request.baseUrl,
19
- method: request.method,
20
- status: statusCode <= 399 ? 'SUCCESS' : 'ERROR',
21
- statusCode: statusCode,
22
- error: {
23
- name: error.name,
24
- message: error.message,
25
- stack: error.stack,
26
- },
27
- };
28
- response.status(statusCode).send(body);
29
- }
30
- exports.defaultErrorHandler = defaultErrorHandler;