c2-http 1.0.82 → 1.0.84
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/dist/index.d.ts +5 -1
- package/dist/index.js +15 -1
- package/dist/model/CrudController.d.ts +2 -0
- package/dist/model/CrudController.js +6 -20
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,8 @@ import { IControllerOptions } from "./model/IControllerOptions";
|
|
|
8
8
|
import { ICrudControllerOptions } from "./model/ICrudControllerOptions";
|
|
9
9
|
import { IServerConfig, Server } from "./model/Server";
|
|
10
10
|
export declare const convertErrorToHttpError: (error: any) => HttpError;
|
|
11
|
-
export
|
|
11
|
+
export declare const prepareRequestParams: (options?: any) => {
|
|
12
|
+
params: any;
|
|
13
|
+
paramsSerializer: (params: any) => string;
|
|
14
|
+
};
|
|
15
|
+
export { Controller, ControllerRoleMiddleware, ControllerRoute, CrudController, getMessage, HttpDispatchDownload, HttpDispatchHandling, IControllerOptions, ICrudControllerOptions, initializei18n, IOpenApiPath, IServerConfig, OpenApi, Server };
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.Server = exports.OpenApi = exports.initializei18n = exports.HttpDispatchHandling = exports.HttpDispatchDownload = exports.getMessage = exports.CrudController = exports.ControllerRoute = exports.ControllerRoleMiddleware = exports.Controller = exports.prepareRequestParams = exports.convertErrorToHttpError = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const express_http_context_1 = __importDefault(require("express-http-context"));
|
|
9
9
|
const http_status_1 = require("http-status");
|
|
10
10
|
const mongodb_1 = require("mongodb");
|
|
11
11
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
12
|
+
const qs_1 = __importDefault(require("qs"));
|
|
12
13
|
const i18n_1 = require("./i18n");
|
|
13
14
|
Object.defineProperty(exports, "getMessage", { enumerable: true, get: function () { return i18n_1.getMessage; } });
|
|
14
15
|
Object.defineProperty(exports, "initializei18n", { enumerable: true, get: function () { return i18n_1.initializei18n; } });
|
|
@@ -124,3 +125,16 @@ const convertErrorToHttpError = (error) => {
|
|
|
124
125
|
});
|
|
125
126
|
};
|
|
126
127
|
exports.convertErrorToHttpError = convertErrorToHttpError;
|
|
128
|
+
const prepareRequestParams = (options) => {
|
|
129
|
+
if (options && options?.searchText === "undefined") {
|
|
130
|
+
options.searchText = "";
|
|
131
|
+
}
|
|
132
|
+
const params = {
|
|
133
|
+
params: options,
|
|
134
|
+
paramsSerializer: (params) => {
|
|
135
|
+
return qs_1.default.stringify(params);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
return params;
|
|
139
|
+
};
|
|
140
|
+
exports.prepareRequestParams = prepareRequestParams;
|
|
@@ -4,11 +4,13 @@ import { ICrudControllerOptions } from "./ICrudControllerOptions";
|
|
|
4
4
|
export declare abstract class CrudController extends Controller {
|
|
5
5
|
constructor(options: ICrudControllerOptions);
|
|
6
6
|
abstract search(request: Request, response: Response): Promise<[number, any]>;
|
|
7
|
+
abstract deepSearch(request: Request, response: Response): Promise<[number, any]>;
|
|
7
8
|
abstract getById(request: Request, response: Response): Promise<[number, any]>;
|
|
8
9
|
abstract create(request: Request, response: Response): Promise<[number, any]>;
|
|
9
10
|
abstract update(request: Request, response: Response): Promise<[number, any]>;
|
|
10
11
|
abstract delete(request: Request, response: Response): Promise<[number, any]>;
|
|
11
12
|
searchRunner(request: Request, response: Response): Promise<[number, any]>;
|
|
13
|
+
deepSearchRunner(request: Request, response: Response): Promise<[number, any]>;
|
|
12
14
|
getByIdRunner(request: Request, response: Response): Promise<[number, any]>;
|
|
13
15
|
createRunner(request: Request, response: Response): Promise<[number, any]>;
|
|
14
16
|
updateRunner(request: Request, response: Response): Promise<[number, any]>;
|
|
@@ -19,11 +19,6 @@ class CrudController extends Controller_1.Controller {
|
|
|
19
19
|
this.updateRunner = this.updateRunner.bind(this);
|
|
20
20
|
this.deleteRunner = this.deleteRunner.bind(this);
|
|
21
21
|
if (options.byPass === true || options.middlewareCheckAuthorization === undefined) {
|
|
22
|
-
// this.routers.get(`${this.options.uri}/:id`, this.getByIdRunner)
|
|
23
|
-
// this.routers.get(`${this.options.uri}`, this.searchRunner)
|
|
24
|
-
// this.routers.post(`${this.options.uri}`, this.createRunner)
|
|
25
|
-
// this.routers.patch(`${this.options.uri}/:id`, this.updateRunner)
|
|
26
|
-
// this.routers.delete(`${this.options.uri}/:id`, this.deleteRunner)
|
|
27
22
|
this.routesControlled.push(new ControllerRoute_1.ControllerRoute({
|
|
28
23
|
router: this.routers,
|
|
29
24
|
method: "get",
|
|
@@ -56,21 +51,6 @@ class CrudController extends Controller_1.Controller {
|
|
|
56
51
|
}));
|
|
57
52
|
}
|
|
58
53
|
else {
|
|
59
|
-
// this.routers.get(`${this.options.uri}/:id`,
|
|
60
|
-
// options.middlewareRoles([`${this.options.prefixRole}:read`]),
|
|
61
|
-
// this.getByIdRunner)
|
|
62
|
-
// this.routers.get(`${this.options.uri}`,
|
|
63
|
-
// options.middlewareRoles([`${this.options.prefixRole}:read`]),
|
|
64
|
-
// this.searchRunner)
|
|
65
|
-
// this.routers.post(`${this.options.uri}`,
|
|
66
|
-
// options.middlewareRoles([`${this.options.prefixRole}:create`]),
|
|
67
|
-
// this.createRunner)
|
|
68
|
-
// this.routers.patch(`${this.options.uri}/:id`,
|
|
69
|
-
// options.middlewareRoles([`${this.options.prefixRole}:edit`]),
|
|
70
|
-
// this.updateRunner)
|
|
71
|
-
// this.routers.delete(`${this.options.uri}/:id`,
|
|
72
|
-
// options.middlewareRoles([`${this.options.prefixRole}:delete`]),
|
|
73
|
-
// this.deleteRunner)
|
|
74
54
|
this.routesControlled.push(new ControllerRoute_1.ControllerRoute({
|
|
75
55
|
router: this.routers,
|
|
76
56
|
method: "get",
|
|
@@ -111,6 +91,9 @@ class CrudController extends Controller_1.Controller {
|
|
|
111
91
|
async searchRunner(request, response) {
|
|
112
92
|
return await this.search(request, response);
|
|
113
93
|
}
|
|
94
|
+
async deepSearchRunner(request, response) {
|
|
95
|
+
return await this.deepSearch(request, response);
|
|
96
|
+
}
|
|
114
97
|
async getByIdRunner(request, response) {
|
|
115
98
|
return await this.getById(request, response);
|
|
116
99
|
}
|
|
@@ -127,6 +110,9 @@ class CrudController extends Controller_1.Controller {
|
|
|
127
110
|
__decorate([
|
|
128
111
|
Controller_1.HttpDispatchHandling
|
|
129
112
|
], CrudController.prototype, "searchRunner", null);
|
|
113
|
+
__decorate([
|
|
114
|
+
Controller_1.HttpDispatchHandling
|
|
115
|
+
], CrudController.prototype, "deepSearchRunner", null);
|
|
130
116
|
__decorate([
|
|
131
117
|
Controller_1.HttpDispatchHandling
|
|
132
118
|
], CrudController.prototype, "getByIdRunner", null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c2-http",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.84",
|
|
4
4
|
"description": "Biblioteca Typescript para API NodeJS",
|
|
5
5
|
"repository": "https://cabralsilva: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@github.com/cabralsilva/c2-http.git",
|
|
6
6
|
"author": "Daniel Cabral <cabralconsultoriaemsoftware@gmail.com>",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"express-rest-i18n": "^1.0.1",
|
|
32
32
|
"http-status": "^1.7.4",
|
|
33
33
|
"mongoose": "^8.3.4",
|
|
34
|
+
"qs": "^6.13.0",
|
|
34
35
|
"swagger-autogen": "^2.23.7",
|
|
35
36
|
"swagger-ui-express": "^5.0.0",
|
|
36
37
|
"ts-node": "^10.8.1",
|