framework-do-dede 0.0.53 → 0.0.54
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.
|
@@ -60,8 +60,10 @@ export default class ControllerHandler {
|
|
|
60
60
|
const capturedError = this.extractError(error, httpServer);
|
|
61
61
|
requestMetrics.error = capturedError;
|
|
62
62
|
input.setStatus(capturedError.statusCode);
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
return {
|
|
64
|
+
message: capturedError.message,
|
|
65
|
+
statusCode: capturedError.statusCode
|
|
66
|
+
};
|
|
65
67
|
}
|
|
66
68
|
finally {
|
|
67
69
|
requestMetrics.endTime = performance.now();
|
|
@@ -74,12 +76,6 @@ export default class ControllerHandler {
|
|
|
74
76
|
}
|
|
75
77
|
httpServer.listen(port);
|
|
76
78
|
}
|
|
77
|
-
// if (error instanceof ServerError) {
|
|
78
|
-
// res.status(error.getStatusCode())
|
|
79
|
-
// throw error;
|
|
80
|
-
// }
|
|
81
|
-
// res.status(500)
|
|
82
|
-
// throw new InternalServerError(error.message, this.defaultMessageError)
|
|
83
79
|
registryControllers() {
|
|
84
80
|
const registryControllers = Registry.resolve('controllers');
|
|
85
81
|
const controllers = [];
|
package/dist/http/HttpServer.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { FrameworkError } from "./FrameworkError";
|
|
2
|
-
import { InternalServerError, ServerError } from "./ServerError";
|
|
3
2
|
export default class HttpServer {
|
|
4
3
|
framework;
|
|
5
4
|
frameworkName;
|
|
@@ -58,34 +57,14 @@ export default class HttpServer {
|
|
|
58
57
|
const method = httpServerParams.method;
|
|
59
58
|
this.framework[method](route, async (request, res) => {
|
|
60
59
|
request.headers['ip'] = request.ip;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return res.status(httpServerParams.statusCode ?? 200).json(output);
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
if (error instanceof ServerError) {
|
|
73
|
-
res.status(error.getStatusCode());
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
res.status(500);
|
|
77
|
-
throw new InternalServerError(error.message, this.defaultMessageError);
|
|
78
|
-
// if (error instanceof ServerError) {
|
|
79
|
-
// return res.status(error.getStatusCode()).json({
|
|
80
|
-
// error: error.message,
|
|
81
|
-
// statusCode: error.getStatusCode()
|
|
82
|
-
// })
|
|
83
|
-
// }
|
|
84
|
-
// return res.status(500).json({
|
|
85
|
-
// error: this.defaultMessageError,
|
|
86
|
-
// statusCode: 500
|
|
87
|
-
// })
|
|
88
|
-
}
|
|
60
|
+
const output = await handler({
|
|
61
|
+
setStatus: (statusCode) => res.status(statusCode),
|
|
62
|
+
headers: request.headers,
|
|
63
|
+
query: request.query,
|
|
64
|
+
params: request.params,
|
|
65
|
+
body: request.body
|
|
66
|
+
});
|
|
67
|
+
return res.status(httpServerParams.statusCode ?? 200).json(output);
|
|
89
68
|
});
|
|
90
69
|
}
|
|
91
70
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Dede, Register as DedeRegister, Options as DedeOptions } from './dede';
|
|
2
2
|
import { Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Auth, Inject, Restrict, Metrics, OffConsoleLog } from './decorators';
|
|
3
3
|
import { BadRequest, Conflict, Forbidden, HttpServer, NotFound, ServerError, Unauthorized, UnprocessableEntity } from './http';
|
|
4
|
-
import { Validation, HttpMiddleware, UseCase, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository, RequestMetricsHandler, RequestData, RequestMetrics } from './protocols';
|
|
4
|
+
import { Validation, HttpMiddleware, UseCase, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository, RequestMetricsHandler, RequestData, RequestMetrics, HttpServerError } from './protocols';
|
|
5
5
|
import { Entity } from './domain/Entity';
|
|
6
6
|
declare class UseCaseHandler {
|
|
7
7
|
static load<T extends UseCase<any, any>>(useCaseClass: new (...args: any[]) => T, request?: RequestData): T;
|
|
8
8
|
}
|
|
9
|
-
export { UseCase, HttpMiddleware, Validation, RequestMetricsHandler, RequestMetrics, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository, RequestData, Dede, DedeRegister, DedeOptions, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Auth, Inject, Entity, Restrict, Metrics, OffConsoleLog };
|
|
9
|
+
export { UseCase, HttpMiddleware, Validation, RequestMetricsHandler, RequestMetrics, HttpServerError, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository, RequestData, Dede, DedeRegister, DedeOptions, UseCaseHandler, ServerError, BadRequest, Conflict, Forbidden, HttpServer, NotFound, Unauthorized, UnprocessableEntity, Controller, Post, Put, Get, Delete, Patch, Validator, Middleware, Auth, Inject, Entity, Restrict, Metrics, OffConsoleLog };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -8,4 +8,5 @@ import type { RestoreRepository } from './RestoreRepository';
|
|
|
8
8
|
import type { RequestMetricsHandler } from './RequestMetricsHandler';
|
|
9
9
|
import type { RequestData } from './RequestData';
|
|
10
10
|
import type { RequestMetrics } from './RequestMetrics';
|
|
11
|
-
|
|
11
|
+
import type { HttpServerError } from './HttpServerError';
|
|
12
|
+
export type { RequestData, RequestMetrics, HttpMiddleware, UseCase, Validation, CreateRepository, DeleteRepository, UpdateRepository, RestoreRepository, RequestMetricsHandler, HttpServerError };
|