@ug.software/opposer 3.0.10 → 3.0.11
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/lib/bin/commands/build.js +15 -28
- package/lib/bin/commands/init.js +27 -30
- package/lib/esm/server/security/jwt/index.d.ts +1 -1
- package/lib/esm/server/security/jwt/index.js +21 -29
- package/lib/esm/system/index.d.ts +1 -1
- package/lib/esm/system/index.js +42 -55
- package/package.json +3 -3
- package/lib/cjs/examples/full-app/index.d.ts +0 -1
- package/lib/cjs/examples/full-app/index.js +0 -102
- package/lib/cjs/examples/full-app/models/author.d.ts +0 -7
- package/lib/cjs/examples/full-app/models/author.js +0 -42
- package/lib/cjs/examples/full-app/models/book.d.ts +0 -9
- package/lib/cjs/examples/full-app/models/book.js +0 -51
- package/lib/cjs/examples/full-app/models/category.d.ts +0 -4
- package/lib/cjs/examples/full-app/models/category.js +0 -26
- package/lib/cjs/examples/full-app/schedules/catalog-refresh.d.ts +0 -28
- package/lib/cjs/examples/full-app/schedules/catalog-refresh.js +0 -149
- package/lib/cjs/examples/full-app/schedules/inventory-sync.d.ts +0 -12
- package/lib/cjs/examples/full-app/schedules/inventory-sync.js +0 -61
- package/lib/cjs/examples/full-app/schedules/library-alerts.d.ts +0 -11
- package/lib/cjs/examples/full-app/schedules/library-alerts.js +0 -55
- package/lib/cjs/examples/minimal/src/handlers/book.d.ts +0 -11
- package/lib/cjs/examples/minimal/src/handlers/book.js +0 -51
- package/lib/cjs/examples/minimal/src/index.d.ts +0 -1
- package/lib/cjs/examples/minimal/src/index.js +0 -14
- package/lib/cjs/examples/minimal/src/models/books.d.ts +0 -4
- package/lib/cjs/examples/minimal/src/models/books.js +0 -26
- package/lib/cjs/examples/orm/models/permission.d.ts +0 -6
- package/lib/cjs/examples/orm/models/permission.js +0 -38
- package/lib/cjs/examples/orm/models/profile.d.ts +0 -7
- package/lib/cjs/examples/orm/models/profile.js +0 -42
- package/lib/cjs/examples/orm/models/user.d.ts +0 -11
- package/lib/cjs/examples/orm/models/user.js +0 -70
- package/lib/cjs/examples/orm/mysql/index.d.ts +0 -1
- package/lib/cjs/examples/orm/mysql/index.js +0 -44
- package/lib/cjs/examples/orm/postgres/index.d.ts +0 -1
- package/lib/cjs/examples/orm/postgres/index.js +0 -40
- package/lib/cjs/examples/orm/sqlite/index.d.ts +0 -1
- package/lib/cjs/examples/orm/sqlite/index.js +0 -41
- package/lib/cjs/index.d.ts +0 -2
- package/lib/cjs/index.js +0 -23
- package/lib/cjs/interfaces/controller.d.ts +0 -109
- package/lib/cjs/interfaces/controller.js +0 -2
- package/lib/cjs/interfaces/field.d.ts +0 -23
- package/lib/cjs/interfaces/field.js +0 -2
- package/lib/cjs/interfaces/handler.d.ts +0 -18
- package/lib/cjs/interfaces/handler.js +0 -2
- package/lib/cjs/interfaces/jwt.d.ts +0 -21
- package/lib/cjs/interfaces/jwt.js +0 -2
- package/lib/cjs/interfaces/model.d.ts +0 -9
- package/lib/cjs/interfaces/model.js +0 -2
- package/lib/cjs/interfaces/request.d.ts +0 -13
- package/lib/cjs/interfaces/request.js +0 -2
- package/lib/cjs/interfaces/schema.d.ts +0 -9
- package/lib/cjs/interfaces/schema.js +0 -2
- package/lib/cjs/interfaces/security.d.ts +0 -32
- package/lib/cjs/interfaces/security.js +0 -2
- package/lib/cjs/interfaces/server.d.ts +0 -37
- package/lib/cjs/interfaces/server.js +0 -2
- package/lib/cjs/interfaces/system.d.ts +0 -41
- package/lib/cjs/interfaces/system.js +0 -2
- package/lib/cjs/orm/decorators/index.d.ts +0 -33
- package/lib/cjs/orm/decorators/index.js +0 -131
- package/lib/cjs/orm/driver/mysql.d.ts +0 -14
- package/lib/cjs/orm/driver/mysql.js +0 -103
- package/lib/cjs/orm/driver/postgres.d.ts +0 -14
- package/lib/cjs/orm/driver/postgres.js +0 -105
- package/lib/cjs/orm/driver/sqlite.d.ts +0 -14
- package/lib/cjs/orm/driver/sqlite.js +0 -143
- package/lib/cjs/orm/index.d.ts +0 -8
- package/lib/cjs/orm/index.js +0 -28
- package/lib/cjs/orm/metadata.d.ts +0 -47
- package/lib/cjs/orm/metadata.js +0 -47
- package/lib/cjs/orm/opposer.d.ts +0 -30
- package/lib/cjs/orm/opposer.js +0 -33
- package/lib/cjs/orm/query-builder.d.ts +0 -32
- package/lib/cjs/orm/query-builder.js +0 -278
- package/lib/cjs/orm/repository.d.ts +0 -54
- package/lib/cjs/orm/repository.js +0 -325
- package/lib/cjs/orm/validation.d.ts +0 -44
- package/lib/cjs/orm/validation.js +0 -128
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/persistent/cache/core-context.d.ts +0 -17
- package/lib/cjs/persistent/cache/core-context.js +0 -39
- package/lib/cjs/persistent/cache/global.d.ts +0 -18
- package/lib/cjs/persistent/cache/global.js +0 -22
- package/lib/cjs/persistent/cache/index.d.ts +0 -3
- package/lib/cjs/persistent/cache/index.js +0 -12
- package/lib/cjs/persistent/cache/session.d.ts +0 -19
- package/lib/cjs/persistent/cache/session.js +0 -39
- package/lib/cjs/persistent/cache/storage.d.ts +0 -14
- package/lib/cjs/persistent/cache/storage.js +0 -88
- package/lib/cjs/persistent/cache/store.d.ts +0 -16
- package/lib/cjs/persistent/cache/store.js +0 -112
- package/lib/cjs/persistent/context/index.d.ts +0 -3
- package/lib/cjs/persistent/context/index.js +0 -5
- package/lib/cjs/persistent/decorators/global.d.ts +0 -1
- package/lib/cjs/persistent/decorators/global.js +0 -25
- package/lib/cjs/persistent/decorators/session.d.ts +0 -1
- package/lib/cjs/persistent/decorators/session.js +0 -27
- package/lib/cjs/persistent/index.d.ts +0 -6
- package/lib/cjs/persistent/index.js +0 -18
- package/lib/cjs/persistent/interfaces/context.d.ts +0 -5
- package/lib/cjs/persistent/interfaces/context.js +0 -2
- package/lib/cjs/persistent/interfaces/system.d.ts +0 -47
- package/lib/cjs/persistent/interfaces/system.js +0 -29
- package/lib/cjs/persistent/system/index.d.ts +0 -7
- package/lib/cjs/persistent/system/index.js +0 -44
- package/lib/cjs/persistent/utils/memory.d.ts +0 -8
- package/lib/cjs/persistent/utils/memory.js +0 -44
- package/lib/cjs/persistent/utils/timer.d.ts +0 -14
- package/lib/cjs/persistent/utils/timer.js +0 -21
- package/lib/cjs/playground/build/client/assets/AddRounded-ByHfnsiW.js +0 -4
- package/lib/cjs/playground/build/client/assets/Button-DLrxHRm7.js +0 -1
- package/lib/cjs/playground/build/client/assets/Container-CgITmmbk.js +0 -1
- package/lib/cjs/playground/build/client/assets/Divider-B_Wx9srO.js +0 -1
- package/lib/cjs/playground/build/client/assets/List-juBjUmfP.js +0 -1
- package/lib/cjs/playground/build/client/assets/ListItemText-DgWZmgzc.js +0 -1
- package/lib/cjs/playground/build/client/assets/MenuItem-D_5SuVKQ.js +0 -1
- package/lib/cjs/playground/build/client/assets/Modal-BwXR_5Bh.js +0 -1
- package/lib/cjs/playground/build/client/assets/TableRow-B9hAmlnV.js +0 -2
- package/lib/cjs/playground/build/client/assets/TextField-UybdTIGB.js +0 -3
- package/lib/cjs/playground/build/client/assets/Tooltip-BGcUWUcF.js +0 -1
- package/lib/cjs/playground/build/client/assets/auth-CD1rXHzz.js +0 -1
- package/lib/cjs/playground/build/client/assets/auth-GyTIVKy5.js +0 -1
- package/lib/cjs/playground/build/client/assets/confirm-Dr0pbiV6.js +0 -1
- package/lib/cjs/playground/build/client/assets/dividerClasses-CIiqeEPO.js +0 -1
- package/lib/cjs/playground/build/client/assets/entry.client-D6FYz1yh.js +0 -13
- package/lib/cjs/playground/build/client/assets/index-CJ0wdt6Z.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-CQc11yq_.js +0 -1153
- package/lib/cjs/playground/build/client/assets/index-Cr4I-4J2.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-CtPqstFl.js +0 -26
- package/lib/cjs/playground/build/client/assets/index-Ct_NE85o.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-D0I6xwmb.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-DmDCpKb3.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-DsSkAwyn.js +0 -1
- package/lib/cjs/playground/build/client/assets/index-_DMgWZ3Y.js +0 -1
- package/lib/cjs/playground/build/client/assets/listItemIconClasses-39Itzgzt.js +0 -1
- package/lib/cjs/playground/build/client/assets/listItemTextClasses-EQFLPLzt.js +0 -1
- package/lib/cjs/playground/build/client/assets/manifest-c06e9a7f.js +0 -1
- package/lib/cjs/playground/build/client/assets/mergeSlotProps-DptgQgAT.js +0 -1
- package/lib/cjs/playground/build/client/assets/playground-Hl52p9f5.js +0 -108
- package/lib/cjs/playground/build/client/assets/root-CQTBmuv8.js +0 -1
- package/lib/cjs/playground/build/client/assets/toast-CsAH5FIf.js +0 -1
- package/lib/cjs/playground/build/client/assets/use-request-BZNkzlTr.js +0 -1
- package/lib/cjs/playground/build/client/favicon.ico +0 -0
- package/lib/cjs/playground/build/client/index.html +0 -6
- package/lib/cjs/playground/index.d.ts +0 -2
- package/lib/cjs/playground/index.js +0 -135
- package/lib/cjs/scheduler/controllers/index.d.ts +0 -19
- package/lib/cjs/scheduler/controllers/index.js +0 -62
- package/lib/cjs/scheduler/decorators/index.d.ts +0 -9
- package/lib/cjs/scheduler/decorators/index.js +0 -21
- package/lib/cjs/scheduler/handlers/index.d.ts +0 -19
- package/lib/cjs/scheduler/handlers/index.js +0 -62
- package/lib/cjs/scheduler/index.d.ts +0 -24
- package/lib/cjs/scheduler/index.js +0 -110
- package/lib/cjs/scheduler/models/history.d.ts +0 -10
- package/lib/cjs/scheduler/models/history.js +0 -50
- package/lib/cjs/server/constants/index.d.ts +0 -78
- package/lib/cjs/server/constants/index.js +0 -372
- package/lib/cjs/server/context/index.d.ts +0 -17
- package/lib/cjs/server/context/index.js +0 -33
- package/lib/cjs/server/controller/index.d.ts +0 -3
- package/lib/cjs/server/controller/index.js +0 -217
- package/lib/cjs/server/controllers/index.d.ts +0 -5
- package/lib/cjs/server/controllers/index.js +0 -72
- package/lib/cjs/server/core/index.d.ts +0 -16
- package/lib/cjs/server/core/index.js +0 -110
- package/lib/cjs/server/core/middleware/body-parser.d.ts +0 -2
- package/lib/cjs/server/core/middleware/body-parser.js +0 -27
- package/lib/cjs/server/core/middleware/cors.d.ts +0 -4
- package/lib/cjs/server/core/middleware/cors.js +0 -32
- package/lib/cjs/server/core/middleware/logger.d.ts +0 -2
- package/lib/cjs/server/core/middleware/logger.js +0 -15
- package/lib/cjs/server/decorators/controller.d.ts +0 -3
- package/lib/cjs/server/decorators/controller.js +0 -14
- package/lib/cjs/server/decorators/field.d.ts +0 -2
- package/lib/cjs/server/decorators/field.js +0 -36
- package/lib/cjs/server/decorators/handler.d.ts +0 -3
- package/lib/cjs/server/decorators/handler.js +0 -14
- package/lib/cjs/server/decorators/index.d.ts +0 -7
- package/lib/cjs/server/decorators/index.js +0 -26
- package/lib/cjs/server/decorators/is-public-method.d.ts +0 -3
- package/lib/cjs/server/decorators/is-public-method.js +0 -16
- package/lib/cjs/server/decorators/is-public.d.ts +0 -3
- package/lib/cjs/server/decorators/is-public.js +0 -14
- package/lib/cjs/server/decorators/method.d.ts +0 -3
- package/lib/cjs/server/decorators/method.js +0 -16
- package/lib/cjs/server/decorators/payload.d.ts +0 -3
- package/lib/cjs/server/decorators/payload.js +0 -15
- package/lib/cjs/server/handlers/index.d.ts +0 -5
- package/lib/cjs/server/handlers/index.js +0 -72
- package/lib/cjs/server/helpers/index.d.ts +0 -17
- package/lib/cjs/server/helpers/index.js +0 -39
- package/lib/cjs/server/index.d.ts +0 -12
- package/lib/cjs/server/index.js +0 -176
- package/lib/cjs/server/security/controller/auth.d.ts +0 -76
- package/lib/cjs/server/security/controller/auth.js +0 -346
- package/lib/cjs/server/security/index.d.ts +0 -2
- package/lib/cjs/server/security/index.js +0 -10
- package/lib/cjs/server/security/jwt/index.d.ts +0 -23
- package/lib/cjs/server/security/jwt/index.js +0 -108
- package/lib/cjs/server/security/middleware/autorization.d.ts +0 -3
- package/lib/cjs/server/security/middleware/autorization.js +0 -46
- package/lib/cjs/server/security/middleware/permission.d.ts +0 -3
- package/lib/cjs/server/security/middleware/permission.js +0 -138
- package/lib/cjs/server/security/models/crp.d.ts +0 -8
- package/lib/cjs/server/security/models/crp.js +0 -42
- package/lib/cjs/server/security/models/ke.d.ts +0 -7
- package/lib/cjs/server/security/models/ke.js +0 -38
- package/lib/cjs/server/security/models/rl.d.ts +0 -9
- package/lib/cjs/server/security/models/rl.js +0 -50
- package/lib/cjs/server/security/models/se.d.ts +0 -11
- package/lib/cjs/server/security/models/se.js +0 -54
- package/lib/cjs/server/security/models/usr.d.ts +0 -14
- package/lib/cjs/server/security/models/usr.js +0 -82
- package/lib/cjs/server/services/delete.d.ts +0 -13
- package/lib/cjs/server/services/delete.js +0 -49
- package/lib/cjs/server/services/get.d.ts +0 -4
- package/lib/cjs/server/services/get.js +0 -145
- package/lib/cjs/server/services/insert.d.ts +0 -13
- package/lib/cjs/server/services/insert.js +0 -74
- package/lib/cjs/server/services/update.d.ts +0 -13
- package/lib/cjs/server/services/update.js +0 -60
- package/lib/cjs/system/index.d.ts +0 -13
- package/lib/cjs/system/index.js +0 -237
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.toKebabCase = toKebabCase;
|
|
40
|
-
exports.toCamelCase = toCamelCase;
|
|
41
|
-
exports.loadControllers = loadControllers;
|
|
42
|
-
const index_js_1 = __importDefault(require("../../system/index.js"));
|
|
43
|
-
const decorator = __importStar(require("../decorators/index.js"));
|
|
44
|
-
const controllers = {};
|
|
45
|
-
function toKebabCase(str) {
|
|
46
|
-
return str
|
|
47
|
-
.replace(/([a-z0-9])([A-Z])/g, "$1-$2") // adiciona hífen antes de maiúsculas
|
|
48
|
-
.replace(/([A-Z])([A-Z][a-z])/g, "$1-$2") // caso AAAa
|
|
49
|
-
.toLowerCase();
|
|
50
|
-
}
|
|
51
|
-
function toCamelCase(str) {
|
|
52
|
-
return str
|
|
53
|
-
.toLowerCase()
|
|
54
|
-
.replace(/-([a-z0-9])/g, (_, char) => char.toUpperCase());
|
|
55
|
-
}
|
|
56
|
-
// function responsible per cache controllers in project;
|
|
57
|
-
async function loadControllers(customControllers) {
|
|
58
|
-
var __allControllers = await index_js_1.default.getAllControllers(customControllers);
|
|
59
|
-
if (Array.isArray(__allControllers) && Object.keys(controllers).length === 0) {
|
|
60
|
-
return __allControllers.reduce((controllers, controller) => {
|
|
61
|
-
var controllerMetadata = decorator.getControllerMetadata(controller);
|
|
62
|
-
var methodsMetadata = decorator.getMethodMetadata(controller);
|
|
63
|
-
controllers[controllerMetadata.name] = {
|
|
64
|
-
metadata: controllerMetadata,
|
|
65
|
-
methods: Array.isArray(methodsMetadata) ? methodsMetadata : [],
|
|
66
|
-
controller: controller,
|
|
67
|
-
};
|
|
68
|
-
return controllers;
|
|
69
|
-
}, controllers);
|
|
70
|
-
}
|
|
71
|
-
return controllers;
|
|
72
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import http from 'http';
|
|
2
|
-
import { type Request, type Response, type NextFunction, OpposerServer as IOpposerServer } from '../../interfaces/server.js';
|
|
3
|
-
export { Request, Response, NextFunction };
|
|
4
|
-
export type Middleware = (req: Request, res: Response, next: NextFunction) => Promise<void> | void;
|
|
5
|
-
export declare class OpposerServer implements IOpposerServer {
|
|
6
|
-
private middlewares;
|
|
7
|
-
private settings;
|
|
8
|
-
constructor();
|
|
9
|
-
use(middleware: Middleware): this;
|
|
10
|
-
private runMiddlewares;
|
|
11
|
-
handleRequest(req: http.IncomingMessage, res: http.ServerResponse): Promise<void>;
|
|
12
|
-
private parseCookies;
|
|
13
|
-
listen(port: number, callback?: () => void): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
14
|
-
}
|
|
15
|
-
declare const instance: OpposerServer;
|
|
16
|
-
export default instance;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.OpposerServer = void 0;
|
|
7
|
-
const http_1 = __importDefault(require("http"));
|
|
8
|
-
const index_js_1 = __importDefault(require("../../system/index.js"));
|
|
9
|
-
const index_js_2 = __importDefault(require("../../persistent/context/index.js"));
|
|
10
|
-
class OpposerServer {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.middlewares = [];
|
|
13
|
-
this.settings = index_js_1.default.getSettingsFile();
|
|
14
|
-
}
|
|
15
|
-
use(middleware) {
|
|
16
|
-
this.middlewares.push(middleware);
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
async runMiddlewares(req, res) {
|
|
20
|
-
let index = 0;
|
|
21
|
-
const next = async () => {
|
|
22
|
-
if (index < this.middlewares.length) {
|
|
23
|
-
const middleware = this.middlewares[index++];
|
|
24
|
-
await middleware(req, res, next);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
await next();
|
|
28
|
-
}
|
|
29
|
-
async handleRequest(req, res) {
|
|
30
|
-
const extendedReq = req;
|
|
31
|
-
const extendedRes = res;
|
|
32
|
-
await index_js_2.default.run({ server: this, req: extendedReq, res: extendedRes }, async () => {
|
|
33
|
-
// Inject server instance into request for easy access
|
|
34
|
-
extendedReq.server = this;
|
|
35
|
-
// Request properties
|
|
36
|
-
extendedReq.ip = req.socket.remoteAddress;
|
|
37
|
-
extendedReq.cookies = this.parseCookies(req.headers.cookie || '');
|
|
38
|
-
// Response helpers
|
|
39
|
-
extendedRes.status = (code) => {
|
|
40
|
-
extendedRes.statusCode = code;
|
|
41
|
-
return extendedRes;
|
|
42
|
-
};
|
|
43
|
-
extendedRes.json = (data) => {
|
|
44
|
-
if (!res.writableEnded) {
|
|
45
|
-
extendedRes.setHeader('Content-Type', 'application/json');
|
|
46
|
-
extendedRes.end(JSON.stringify(data));
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
extendedRes.send = (data) => {
|
|
50
|
-
if (!res.writableEnded) {
|
|
51
|
-
if (typeof data === 'object')
|
|
52
|
-
return extendedRes.json(data);
|
|
53
|
-
extendedRes.end(data);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
extendedRes.cookie = (name, value, options = {}) => {
|
|
57
|
-
let cookieStr = `${name}=${value}`;
|
|
58
|
-
if (options.httpOnly)
|
|
59
|
-
cookieStr += '; HttpOnly';
|
|
60
|
-
if (options.secure)
|
|
61
|
-
cookieStr += '; Secure';
|
|
62
|
-
if (options.path)
|
|
63
|
-
cookieStr += `; Path=${options.path}`;
|
|
64
|
-
if (options.expires)
|
|
65
|
-
cookieStr += `; Expires=${options.expires.toUTCString()}`;
|
|
66
|
-
if (options.sameSite)
|
|
67
|
-
cookieStr += `; SameSite=${options.sameSite}`;
|
|
68
|
-
const existing = res.getHeader('Set-Cookie');
|
|
69
|
-
if (!existing) {
|
|
70
|
-
res.setHeader('Set-Cookie', [cookieStr]);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
const cookies = Array.isArray(existing) ? existing : [String(existing)];
|
|
74
|
-
cookies.push(cookieStr);
|
|
75
|
-
res.setHeader('Set-Cookie', cookies);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
extendedRes.clearCookie = (name, options = {}) => {
|
|
79
|
-
extendedRes.cookie(name, '', { ...options, expires: new Date(0) });
|
|
80
|
-
};
|
|
81
|
-
try {
|
|
82
|
-
await this.runMiddlewares(extendedReq, extendedRes);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
console.error('[core] Server error:', error);
|
|
86
|
-
if (!res.writableEnded) {
|
|
87
|
-
extendedRes.status(500).json({ message: error.message || 'Internal Server Error' });
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
parseCookies(cookieHeader) {
|
|
93
|
-
const cookies = {};
|
|
94
|
-
cookieHeader.split(';').forEach((cookie) => {
|
|
95
|
-
const parts = cookie.split('=');
|
|
96
|
-
if (parts.length === 2) {
|
|
97
|
-
cookies[parts[0].trim()] = parts[1].trim();
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
return cookies;
|
|
101
|
-
}
|
|
102
|
-
listen(port, callback) {
|
|
103
|
-
const server = http_1.default.createServer((req, res) => this.handleRequest(req, res));
|
|
104
|
-
server.listen(port, callback);
|
|
105
|
-
return server;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
exports.OpposerServer = OpposerServer;
|
|
109
|
-
const instance = new OpposerServer();
|
|
110
|
-
exports.default = instance;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = bodyParser;
|
|
4
|
-
function bodyParser() {
|
|
5
|
-
return async (req, res, next) => {
|
|
6
|
-
if (req.method === "POST" || req.method === "PUT") {
|
|
7
|
-
const chunks = [];
|
|
8
|
-
req.on("data", (chunk) => chunks.push(chunk));
|
|
9
|
-
req.on("end", () => {
|
|
10
|
-
const bodyStr = Buffer.concat(chunks).toString();
|
|
11
|
-
try {
|
|
12
|
-
if (bodyStr) {
|
|
13
|
-
req.body = JSON.parse(bodyStr);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
console.error("[core] JSON parsing error:", e);
|
|
18
|
-
req.body = {};
|
|
19
|
-
}
|
|
20
|
-
next();
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
next();
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = cors;
|
|
4
|
-
function cors(options) {
|
|
5
|
-
return (req, res, next) => {
|
|
6
|
-
const originHeader = req.headers.origin;
|
|
7
|
-
let allowedOrigin = "*";
|
|
8
|
-
if (options?.origin) {
|
|
9
|
-
if (Array.isArray(options.origin)) {
|
|
10
|
-
if (originHeader && options.origin.includes(originHeader)) {
|
|
11
|
-
allowedOrigin = originHeader;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
allowedOrigin = options.origin[0]; // Fallback to first one
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
allowedOrigin = options.origin;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
res.setHeader("Access-Control-Allow-Origin", allowedOrigin);
|
|
22
|
-
res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
|
23
|
-
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, opposer-key");
|
|
24
|
-
res.setHeader("Access-Control-Allow-Credentials", "true");
|
|
25
|
-
if (req.method === "OPTIONS") {
|
|
26
|
-
res.statusCode = 204;
|
|
27
|
-
res.end();
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
next();
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = logger;
|
|
4
|
-
function logger() {
|
|
5
|
-
return (req, res, next) => {
|
|
6
|
-
const start = Date.now();
|
|
7
|
-
const { method, url } = req;
|
|
8
|
-
res.on("finish", () => {
|
|
9
|
-
const duration = Date.now() - start;
|
|
10
|
-
const status = res.statusCode;
|
|
11
|
-
console.log(`[${new Date().toISOString()}] ${method} ${url} - ${status} (${duration}ms)`);
|
|
12
|
-
});
|
|
13
|
-
next();
|
|
14
|
-
};
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = Controller;
|
|
4
|
-
exports.getControllerMetadata = getControllerMetadata;
|
|
5
|
-
require("reflect-metadata");
|
|
6
|
-
const CONTROLLER_KEY = Symbol("controller");
|
|
7
|
-
function Controller(name) {
|
|
8
|
-
return function (constructor) {
|
|
9
|
-
Reflect.defineMetadata(CONTROLLER_KEY, { name }, constructor);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function getControllerMetadata(target) {
|
|
13
|
-
return Reflect.getMetadata(CONTROLLER_KEY, target) || [];
|
|
14
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = Field;
|
|
4
|
-
exports.getFieldsMetadata = getFieldsMetadata;
|
|
5
|
-
const index_js_1 = require("../../orm/index.js");
|
|
6
|
-
const FIELD_KEY = Symbol("field");
|
|
7
|
-
function Field(model) {
|
|
8
|
-
return (target, name, context) => {
|
|
9
|
-
// 1. Legacy server metadata (for existing code that uses getFieldsMetadata)
|
|
10
|
-
const fields = Reflect.getMetadata(FIELD_KEY, target.constructor) || [];
|
|
11
|
-
fields.push({ name, model: typeof model === 'function' ? model() : model });
|
|
12
|
-
Reflect.defineMetadata(FIELD_KEY, fields, target.constructor);
|
|
13
|
-
// 2. ORM metadata (calling the ORM decorator logic)
|
|
14
|
-
const ormDecorator = (0, index_js_1.Field)(typeof model === 'function' ? { validation: model } : model);
|
|
15
|
-
return ormDecorator(target, name);
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function getFieldsMetadata(target) {
|
|
19
|
-
// Try to get from the constructor if target is an instance
|
|
20
|
-
const constructor = typeof target === 'function' ? target : target.constructor;
|
|
21
|
-
// 1. Get from legacy metadata
|
|
22
|
-
const legacyFields = Reflect.getMetadata(FIELD_KEY, constructor) || [];
|
|
23
|
-
// 2. Get from ORM MetadataStore
|
|
24
|
-
const ormFields = index_js_1.MetadataStore.getFields(constructor).map(f => ({
|
|
25
|
-
name: f.name,
|
|
26
|
-
model: { type: f.type }
|
|
27
|
-
}));
|
|
28
|
-
// Combine and remove duplicates (by name)
|
|
29
|
-
const allFields = [...legacyFields];
|
|
30
|
-
ormFields.forEach(of => {
|
|
31
|
-
if (!allFields.find(lf => lf.name === of.name)) {
|
|
32
|
-
allFields.push(of);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return allFields;
|
|
36
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = Controller;
|
|
4
|
-
exports.getControllerMetadata = getControllerMetadata;
|
|
5
|
-
require("reflect-metadata");
|
|
6
|
-
const CONTROLLER_KEY = Symbol("controller");
|
|
7
|
-
function Controller(name) {
|
|
8
|
-
return function (constructor) {
|
|
9
|
-
Reflect.defineMetadata(CONTROLLER_KEY, { name }, constructor);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function getControllerMetadata(target) {
|
|
13
|
-
return Reflect.getMetadata(CONTROLLER_KEY, target) || [];
|
|
14
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { default as Method, getMethodMetadata } from "./method.js";
|
|
2
|
-
export { default as Controller, getControllerMetadata } from "./controller.js";
|
|
3
|
-
export { default as Payload, getPayloadMetadata } from "./payload.js";
|
|
4
|
-
export { default as IsPublic, getIsPublicMetadata } from "./is-public.js";
|
|
5
|
-
export { default as IsPublicMethod, getIsPublicMethodMetadata, } from "./is-public-method.js";
|
|
6
|
-
export { default as Field, getFieldsMetadata } from "./field.js";
|
|
7
|
-
export { f } from "../../orm/index.js";
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.f = exports.getFieldsMetadata = exports.Field = exports.getIsPublicMethodMetadata = exports.IsPublicMethod = exports.getIsPublicMetadata = exports.IsPublic = exports.getPayloadMetadata = exports.Payload = exports.getControllerMetadata = exports.Controller = exports.getMethodMetadata = exports.Method = void 0;
|
|
7
|
-
var method_js_1 = require("./method.js");
|
|
8
|
-
Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return __importDefault(method_js_1).default; } });
|
|
9
|
-
Object.defineProperty(exports, "getMethodMetadata", { enumerable: true, get: function () { return method_js_1.getMethodMetadata; } });
|
|
10
|
-
var controller_js_1 = require("./controller.js");
|
|
11
|
-
Object.defineProperty(exports, "Controller", { enumerable: true, get: function () { return __importDefault(controller_js_1).default; } });
|
|
12
|
-
Object.defineProperty(exports, "getControllerMetadata", { enumerable: true, get: function () { return controller_js_1.getControllerMetadata; } });
|
|
13
|
-
var payload_js_1 = require("./payload.js");
|
|
14
|
-
Object.defineProperty(exports, "Payload", { enumerable: true, get: function () { return __importDefault(payload_js_1).default; } });
|
|
15
|
-
Object.defineProperty(exports, "getPayloadMetadata", { enumerable: true, get: function () { return payload_js_1.getPayloadMetadata; } });
|
|
16
|
-
var is_public_js_1 = require("./is-public.js");
|
|
17
|
-
Object.defineProperty(exports, "IsPublic", { enumerable: true, get: function () { return __importDefault(is_public_js_1).default; } });
|
|
18
|
-
Object.defineProperty(exports, "getIsPublicMetadata", { enumerable: true, get: function () { return is_public_js_1.getIsPublicMetadata; } });
|
|
19
|
-
var is_public_method_js_1 = require("./is-public-method.js");
|
|
20
|
-
Object.defineProperty(exports, "IsPublicMethod", { enumerable: true, get: function () { return __importDefault(is_public_method_js_1).default; } });
|
|
21
|
-
Object.defineProperty(exports, "getIsPublicMethodMetadata", { enumerable: true, get: function () { return is_public_method_js_1.getIsPublicMethodMetadata; } });
|
|
22
|
-
var field_js_1 = require("./field.js");
|
|
23
|
-
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return __importDefault(field_js_1).default; } });
|
|
24
|
-
Object.defineProperty(exports, "getFieldsMetadata", { enumerable: true, get: function () { return field_js_1.getFieldsMetadata; } });
|
|
25
|
-
var index_js_1 = require("../../orm/index.js");
|
|
26
|
-
Object.defineProperty(exports, "f", { enumerable: true, get: function () { return index_js_1.f; } });
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = IsPublicMethod;
|
|
4
|
-
exports.getIsPublicMethodMetadata = getIsPublicMethodMetadata;
|
|
5
|
-
require("reflect-metadata");
|
|
6
|
-
const PUBLIC_METHOD_KEY = Symbol("method");
|
|
7
|
-
function IsPublicMethod() {
|
|
8
|
-
return function (target, name, context) {
|
|
9
|
-
const methods = Reflect.getMetadata(PUBLIC_METHOD_KEY, target.constructor) || [];
|
|
10
|
-
methods.push({ name });
|
|
11
|
-
Reflect.defineMetadata(PUBLIC_METHOD_KEY, methods, target.constructor);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function getIsPublicMethodMetadata(target) {
|
|
15
|
-
return Reflect.getMetadata(PUBLIC_METHOD_KEY, target) || [];
|
|
16
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = IsPublic;
|
|
4
|
-
exports.getIsPublicMetadata = getIsPublicMetadata;
|
|
5
|
-
require("reflect-metadata");
|
|
6
|
-
const PUBLIC_KEY = Symbol("is-public");
|
|
7
|
-
function IsPublic() {
|
|
8
|
-
return (target) => {
|
|
9
|
-
Reflect.defineMetadata(PUBLIC_KEY, true, target);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function getIsPublicMetadata(target) {
|
|
13
|
-
return Reflect.getMetadata(PUBLIC_KEY, target) === true;
|
|
14
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = Method;
|
|
4
|
-
exports.getMethodMetadata = getMethodMetadata;
|
|
5
|
-
require("reflect-metadata");
|
|
6
|
-
const METHOD_KEY = Symbol("method");
|
|
7
|
-
function Method() {
|
|
8
|
-
return function (target, name, context) {
|
|
9
|
-
const methods = Reflect.getMetadata(METHOD_KEY, target.constructor) || [];
|
|
10
|
-
methods.push({ name });
|
|
11
|
-
Reflect.defineMetadata(METHOD_KEY, methods, target.constructor);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function getMethodMetadata(target) {
|
|
15
|
-
return Reflect.getMetadata(METHOD_KEY, target) || [];
|
|
16
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = Payload;
|
|
4
|
-
exports.getPayloadMetadata = getPayloadMetadata;
|
|
5
|
-
const PAYLOAD_KEY = Symbol("method");
|
|
6
|
-
function Payload(dto) {
|
|
7
|
-
return function (target, name, context) {
|
|
8
|
-
const payloads = Reflect.getMetadata(PAYLOAD_KEY, target.constructor) || [];
|
|
9
|
-
payloads.push({ name, dto });
|
|
10
|
-
Reflect.defineMetadata(PAYLOAD_KEY, payloads, target.constructor);
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function getPayloadMetadata(target) {
|
|
14
|
-
return Reflect.getMetadata(PAYLOAD_KEY, target) || [];
|
|
15
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ResultGetAllControllers } from "../../interfaces/controller.js";
|
|
2
|
-
import { ClassType } from "../../interfaces/system.js";
|
|
3
|
-
export declare function toKebabCase(str: string): string;
|
|
4
|
-
export declare function toCamelCase(str: string): string;
|
|
5
|
-
export declare function loadControllers(customControllers?: string | ClassType<unknown>[]): Promise<ResultGetAllControllers>;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.toKebabCase = toKebabCase;
|
|
40
|
-
exports.toCamelCase = toCamelCase;
|
|
41
|
-
exports.loadControllers = loadControllers;
|
|
42
|
-
const index_js_1 = __importDefault(require("../../system/index.js"));
|
|
43
|
-
const decorator = __importStar(require("../decorators/index.js"));
|
|
44
|
-
const controllers = {};
|
|
45
|
-
function toKebabCase(str) {
|
|
46
|
-
return str
|
|
47
|
-
.replace(/([a-z0-9])([A-Z])/g, "$1-$2") // adiciona hífen antes de maiúsculas
|
|
48
|
-
.replace(/([A-Z])([A-Z][a-z])/g, "$1-$2") // caso AAAa
|
|
49
|
-
.toLowerCase();
|
|
50
|
-
}
|
|
51
|
-
function toCamelCase(str) {
|
|
52
|
-
return str
|
|
53
|
-
.toLowerCase()
|
|
54
|
-
.replace(/-([a-z0-9])/g, (_, char) => char.toUpperCase());
|
|
55
|
-
}
|
|
56
|
-
// function responsible per cache controllers in project;
|
|
57
|
-
async function loadControllers(customControllers) {
|
|
58
|
-
var __allControllers = await index_js_1.default.getAllControllers(customControllers);
|
|
59
|
-
if (Array.isArray(__allControllers) && Object.keys(controllers).length === 0) {
|
|
60
|
-
return __allControllers.reduce((controllers, controller) => {
|
|
61
|
-
var controllerMetadata = decorator.getControllerMetadata(controller);
|
|
62
|
-
var methodsMetadata = decorator.getMethodMetadata(controller);
|
|
63
|
-
controllers[controllerMetadata.name] = {
|
|
64
|
-
metadata: controllerMetadata,
|
|
65
|
-
methods: Array.isArray(methodsMetadata) ? methodsMetadata : [],
|
|
66
|
-
controller: controller,
|
|
67
|
-
};
|
|
68
|
-
return controllers;
|
|
69
|
-
}, controllers);
|
|
70
|
-
}
|
|
71
|
-
return controllers;
|
|
72
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { HandleRequestResultError } from "../../interfaces/request.js";
|
|
2
|
-
export declare function Success(data: any): {
|
|
3
|
-
readonly success: true;
|
|
4
|
-
readonly data: any;
|
|
5
|
-
};
|
|
6
|
-
export declare function Exception(error: HandleRequestResultError["error"]): {
|
|
7
|
-
readonly success: false;
|
|
8
|
-
readonly error: {
|
|
9
|
-
name: string;
|
|
10
|
-
code: number;
|
|
11
|
-
message: any;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Validates data against a model (Entity or DTO) decorated with @Field
|
|
16
|
-
*/
|
|
17
|
-
export declare function validateData(model: any, values: Record<string, any>): Record<string, string[]>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Success = Success;
|
|
4
|
-
exports.Exception = Exception;
|
|
5
|
-
exports.validateData = validateData;
|
|
6
|
-
const index_js_1 = require("../../orm/index.js");
|
|
7
|
-
function Success(data) {
|
|
8
|
-
return {
|
|
9
|
-
success: true,
|
|
10
|
-
data,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function Exception(error) {
|
|
14
|
-
return {
|
|
15
|
-
success: false,
|
|
16
|
-
error: error,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Validates data against a model (Entity or DTO) decorated with @Field
|
|
21
|
-
*/
|
|
22
|
-
function validateData(model, values) {
|
|
23
|
-
const errors = {};
|
|
24
|
-
// Get fields from MetadataStore (supports both legacy and new ORM decorators)
|
|
25
|
-
const fields = index_js_1.MetadataStore.getFields(model);
|
|
26
|
-
for (const field of fields) {
|
|
27
|
-
const value = values[field.name || field.propertyKey];
|
|
28
|
-
if (field.validation) {
|
|
29
|
-
const validator = typeof field.validation === 'function' ? field.validation() : field.validation;
|
|
30
|
-
if (validator && typeof validator.validate === 'function') {
|
|
31
|
-
const fieldErrors = validator.validate(value, values);
|
|
32
|
-
if (fieldErrors && fieldErrors.length > 0) {
|
|
33
|
-
errors[field.name || field.propertyKey] = fieldErrors;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return errors;
|
|
39
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CreateServerProps, ServerInstance } from '../interfaces/server.js';
|
|
2
|
-
import Auth from './security/controller/auth.js';
|
|
3
|
-
export default function Server(props: CreateServerProps): Promise<ServerInstance>;
|
|
4
|
-
export declare const auth: {
|
|
5
|
-
social: typeof Auth.social;
|
|
6
|
-
};
|
|
7
|
-
export * from './constants/index.js';
|
|
8
|
-
export * from './helpers/index.js';
|
|
9
|
-
export type { ModelResult } from '../interfaces/model.js';
|
|
10
|
-
export { Method, Controller, Field, Payload, IsPublic, IsPublicMethod, f } from './decorators/index.js';
|
|
11
|
-
export type { PayloadRequest } from '../interfaces/controller.js';
|
|
12
|
-
export { default as Context } from './context/index.js';
|