@xbg.solutions/backend-core 1.0.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/lib/core/src/app.d.ts +28 -0
- package/lib/core/src/app.d.ts.map +1 -0
- package/lib/core/src/app.js +188 -0
- package/lib/core/src/app.js.map +1 -0
- package/lib/core/src/base/BaseController.d.ts +108 -0
- package/lib/core/src/base/BaseController.d.ts.map +1 -0
- package/lib/core/src/base/BaseController.js +307 -0
- package/lib/core/src/base/BaseController.js.map +1 -0
- package/lib/core/src/base/BaseEntity.d.ts +92 -0
- package/lib/core/src/base/BaseEntity.d.ts.map +1 -0
- package/lib/core/src/base/BaseEntity.js +143 -0
- package/lib/core/src/base/BaseEntity.js.map +1 -0
- package/lib/core/src/base/BaseRepository.d.ts +124 -0
- package/lib/core/src/base/BaseRepository.d.ts.map +1 -0
- package/lib/core/src/base/BaseRepository.js +414 -0
- package/lib/core/src/base/BaseRepository.js.map +1 -0
- package/lib/core/src/base/BaseService.d.ts +89 -0
- package/lib/core/src/base/BaseService.d.ts.map +1 -0
- package/lib/core/src/base/BaseService.js +342 -0
- package/lib/core/src/base/BaseService.js.map +1 -0
- package/lib/core/src/base/index.d.ts +8 -0
- package/lib/core/src/base/index.d.ts.map +1 -0
- package/lib/core/src/base/index.js +24 -0
- package/lib/core/src/base/index.js.map +1 -0
- package/lib/core/src/config/app.config.d.ts +70 -0
- package/lib/core/src/config/app.config.d.ts.map +1 -0
- package/lib/core/src/config/app.config.js +106 -0
- package/lib/core/src/config/app.config.js.map +1 -0
- package/lib/core/src/config/auth.config.d.ts +54 -0
- package/lib/core/src/config/auth.config.d.ts.map +1 -0
- package/lib/core/src/config/auth.config.js +88 -0
- package/lib/core/src/config/auth.config.js.map +1 -0
- package/lib/core/src/config/cache.config.d.ts +47 -0
- package/lib/core/src/config/cache.config.d.ts.map +1 -0
- package/lib/core/src/config/cache.config.js +225 -0
- package/lib/core/src/config/cache.config.js.map +1 -0
- package/lib/core/src/config/communications.config.d.ts +175 -0
- package/lib/core/src/config/communications.config.d.ts.map +1 -0
- package/lib/core/src/config/communications.config.js +219 -0
- package/lib/core/src/config/communications.config.js.map +1 -0
- package/lib/core/src/config/database.config.d.ts +68 -0
- package/lib/core/src/config/database.config.d.ts.map +1 -0
- package/lib/core/src/config/database.config.js +95 -0
- package/lib/core/src/config/database.config.js.map +1 -0
- package/lib/core/src/config/firebase-event-mapping.config.d.ts +41 -0
- package/lib/core/src/config/firebase-event-mapping.config.d.ts.map +1 -0
- package/lib/core/src/config/firebase-event-mapping.config.js +180 -0
- package/lib/core/src/config/firebase-event-mapping.config.js.map +1 -0
- package/lib/core/src/config/firestore.config.d.ts +61 -0
- package/lib/core/src/config/firestore.config.d.ts.map +1 -0
- package/lib/core/src/config/firestore.config.js +74 -0
- package/lib/core/src/config/firestore.config.js.map +1 -0
- package/lib/core/src/config/index.d.ts +15 -0
- package/lib/core/src/config/index.d.ts.map +1 -0
- package/lib/core/src/config/index.js +41 -0
- package/lib/core/src/config/index.js.map +1 -0
- package/lib/core/src/config/maps.config.d.ts +31 -0
- package/lib/core/src/config/maps.config.d.ts.map +1 -0
- package/lib/core/src/config/maps.config.js +50 -0
- package/lib/core/src/config/maps.config.js.map +1 -0
- package/lib/core/src/config/middleware.config.d.ts +57 -0
- package/lib/core/src/config/middleware.config.d.ts.map +1 -0
- package/lib/core/src/config/middleware.config.js +68 -0
- package/lib/core/src/config/middleware.config.js.map +1 -0
- package/lib/core/src/config/tokens.config.d.ts +53 -0
- package/lib/core/src/config/tokens.config.d.ts.map +1 -0
- package/lib/core/src/config/tokens.config.js +129 -0
- package/lib/core/src/config/tokens.config.js.map +1 -0
- package/lib/core/src/generator/generator.d.ts +38 -0
- package/lib/core/src/generator/generator.d.ts.map +1 -0
- package/lib/core/src/generator/generator.js +159 -0
- package/lib/core/src/generator/generator.js.map +1 -0
- package/lib/core/src/generator/index.d.ts +7 -0
- package/lib/core/src/generator/index.d.ts.map +1 -0
- package/lib/core/src/generator/index.js +23 -0
- package/lib/core/src/generator/index.js.map +1 -0
- package/lib/core/src/generator/parser.d.ts +10 -0
- package/lib/core/src/generator/parser.d.ts.map +1 -0
- package/lib/core/src/generator/parser.js +197 -0
- package/lib/core/src/generator/parser.js.map +1 -0
- package/lib/core/src/generator/types.d.ts +112 -0
- package/lib/core/src/generator/types.d.ts.map +1 -0
- package/lib/core/src/generator/types.js +7 -0
- package/lib/core/src/generator/types.js.map +1 -0
- package/lib/core/src/index.d.ts +19 -0
- package/lib/core/src/index.d.ts.map +1 -0
- package/lib/core/src/index.js +46 -0
- package/lib/core/src/index.js.map +1 -0
- package/lib/core/src/middleware/auth.middleware.d.ts +57 -0
- package/lib/core/src/middleware/auth.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/auth.middleware.js +256 -0
- package/lib/core/src/middleware/auth.middleware.js.map +1 -0
- package/lib/core/src/middleware/cors.middleware.d.ts +13 -0
- package/lib/core/src/middleware/cors.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/cors.middleware.js +50 -0
- package/lib/core/src/middleware/cors.middleware.js.map +1 -0
- package/lib/core/src/middleware/error.middleware.d.ts +46 -0
- package/lib/core/src/middleware/error.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/error.middleware.js +174 -0
- package/lib/core/src/middleware/error.middleware.js.map +1 -0
- package/lib/core/src/middleware/index.d.ts +11 -0
- package/lib/core/src/middleware/index.d.ts.map +1 -0
- package/lib/core/src/middleware/index.js +27 -0
- package/lib/core/src/middleware/index.js.map +1 -0
- package/lib/core/src/middleware/logging.middleware.d.ts +10 -0
- package/lib/core/src/middleware/logging.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/logging.middleware.js +87 -0
- package/lib/core/src/middleware/logging.middleware.js.map +1 -0
- package/lib/core/src/middleware/rateLimit.middleware.d.ts +26 -0
- package/lib/core/src/middleware/rateLimit.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/rateLimit.middleware.js +105 -0
- package/lib/core/src/middleware/rateLimit.middleware.js.map +1 -0
- package/lib/core/src/middleware/requestId.middleware.d.ts +11 -0
- package/lib/core/src/middleware/requestId.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/requestId.middleware.js +26 -0
- package/lib/core/src/middleware/requestId.middleware.js.map +1 -0
- package/lib/core/src/middleware/validation.middleware.d.ts +25 -0
- package/lib/core/src/middleware/validation.middleware.d.ts.map +1 -0
- package/lib/core/src/middleware/validation.middleware.js +133 -0
- package/lib/core/src/middleware/validation.middleware.js.map +1 -0
- package/lib/core/src/types/errors.d.ts +119 -0
- package/lib/core/src/types/errors.d.ts.map +1 -0
- package/lib/core/src/types/errors.js +210 -0
- package/lib/core/src/types/errors.js.map +1 -0
- package/lib/utils-cache-connector/src/cache-connector.d.ts +139 -0
- package/lib/utils-cache-connector/src/cache-connector.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/cache-connector.js +277 -0
- package/lib/utils-cache-connector/src/cache-connector.js.map +1 -0
- package/lib/utils-cache-connector/src/index.d.ts +52 -0
- package/lib/utils-cache-connector/src/index.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/index.js +103 -0
- package/lib/utils-cache-connector/src/index.js.map +1 -0
- package/lib/utils-cache-connector/src/providers/base-cache-provider.d.ts +95 -0
- package/lib/utils-cache-connector/src/providers/base-cache-provider.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/providers/base-cache-provider.js +120 -0
- package/lib/utils-cache-connector/src/providers/base-cache-provider.js.map +1 -0
- package/lib/utils-cache-connector/src/providers/firestore-cache-provider.d.ts +58 -0
- package/lib/utils-cache-connector/src/providers/firestore-cache-provider.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/providers/firestore-cache-provider.js +418 -0
- package/lib/utils-cache-connector/src/providers/firestore-cache-provider.js.map +1 -0
- package/lib/utils-cache-connector/src/providers/memory-cache-provider.d.ts +57 -0
- package/lib/utils-cache-connector/src/providers/memory-cache-provider.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/providers/memory-cache-provider.js +217 -0
- package/lib/utils-cache-connector/src/providers/memory-cache-provider.js.map +1 -0
- package/lib/utils-cache-connector/src/providers/noop-cache-provider.d.ts +21 -0
- package/lib/utils-cache-connector/src/providers/noop-cache-provider.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/providers/noop-cache-provider.js +42 -0
- package/lib/utils-cache-connector/src/providers/noop-cache-provider.js.map +1 -0
- package/lib/utils-cache-connector/src/providers/redis-cache-provider.d.ts +64 -0
- package/lib/utils-cache-connector/src/providers/redis-cache-provider.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/providers/redis-cache-provider.js +414 -0
- package/lib/utils-cache-connector/src/providers/redis-cache-provider.js.map +1 -0
- package/lib/utils-cache-connector/src/types.d.ts +342 -0
- package/lib/utils-cache-connector/src/types.d.ts.map +1 -0
- package/lib/utils-cache-connector/src/types.js +8 -0
- package/lib/utils-cache-connector/src/types.js.map +1 -0
- package/lib/utils-events/src/event-bus.d.ts +42 -0
- package/lib/utils-events/src/event-bus.d.ts.map +1 -0
- package/lib/utils-events/src/event-bus.js +93 -0
- package/lib/utils-events/src/event-bus.js.map +1 -0
- package/lib/utils-events/src/event-types.d.ts +146 -0
- package/lib/utils-events/src/event-types.d.ts.map +1 -0
- package/lib/utils-events/src/event-types.js +49 -0
- package/lib/utils-events/src/event-types.js.map +1 -0
- package/lib/utils-events/src/index.d.ts +7 -0
- package/lib/utils-events/src/index.d.ts.map +1 -0
- package/lib/utils-events/src/index.js +11 -0
- package/lib/utils-events/src/index.js.map +1 -0
- package/lib/utils-logger/src/index.d.ts +12 -0
- package/lib/utils-logger/src/index.d.ts.map +1 -0
- package/lib/utils-logger/src/index.js +29 -0
- package/lib/utils-logger/src/index.js.map +1 -0
- package/lib/utils-logger/src/logger-types.d.ts +32 -0
- package/lib/utils-logger/src/logger-types.d.ts.map +1 -0
- package/lib/utils-logger/src/logger-types.js +17 -0
- package/lib/utils-logger/src/logger-types.js.map +1 -0
- package/lib/utils-logger/src/logger.d.ts +42 -0
- package/lib/utils-logger/src/logger.d.ts.map +1 -0
- package/lib/utils-logger/src/logger.js +123 -0
- package/lib/utils-logger/src/logger.js.map +1 -0
- package/package.json +49 -0
- package/src/templates/controller.hbs +48 -0
- package/src/templates/entity.hbs +80 -0
- package/src/templates/repository.hbs +56 -0
- package/src/templates/service.hbs +108 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Express Application Setup
|
|
3
|
+
* Configures middleware pipeline and route registration
|
|
4
|
+
*/
|
|
5
|
+
import { Express, Router } from 'express';
|
|
6
|
+
export interface AppOptions {
|
|
7
|
+
tokenHandler?: any;
|
|
8
|
+
controllers?: Array<{
|
|
9
|
+
getRouter: () => Router;
|
|
10
|
+
getBasePath: () => string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create and configure Express application
|
|
15
|
+
*/
|
|
16
|
+
export declare function createApp(options?: AppOptions): Express;
|
|
17
|
+
/**
|
|
18
|
+
* Register controllers dynamically
|
|
19
|
+
*/
|
|
20
|
+
export declare function registerControllers(app: Express, controllers: Array<{
|
|
21
|
+
getRouter: () => Router;
|
|
22
|
+
getBasePath: () => string;
|
|
23
|
+
}>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Start Express server (for local development)
|
|
26
|
+
*/
|
|
27
|
+
export declare function startServer(app: Express): void;
|
|
28
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/app.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAcnD,MAAM,WAAW,UAAU;IACzB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,WAAW,CAAC,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,MAAM,CAAA;KAAE,CAAC,CAAC;CAC7E;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,UAAe,GAAG,OAAO,CA6G3D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,OAAO,EACZ,WAAW,EAAE,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,MAAM,CAAA;CAAE,CAAC,GACzE,IAAI,CAgBN;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CA0B9C"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Express Application Setup
|
|
4
|
+
* Configures middleware pipeline and route registration
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.createApp = createApp;
|
|
44
|
+
exports.registerControllers = registerControllers;
|
|
45
|
+
exports.startServer = startServer;
|
|
46
|
+
const express_1 = __importStar(require("express"));
|
|
47
|
+
const helmet_1 = __importDefault(require("helmet"));
|
|
48
|
+
const config_1 = require("./config");
|
|
49
|
+
const middleware_1 = require("./middleware");
|
|
50
|
+
const utils_logger_1 = require("@xbg/utils-logger");
|
|
51
|
+
/**
|
|
52
|
+
* Create and configure Express application
|
|
53
|
+
*/
|
|
54
|
+
function createApp(options = {}) {
|
|
55
|
+
var _a;
|
|
56
|
+
// Validate configuration
|
|
57
|
+
try {
|
|
58
|
+
(0, config_1.validateAllConfig)();
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
62
|
+
utils_logger_1.logger.error('Configuration validation failed', err);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
const app = (0, express_1.default)();
|
|
66
|
+
// Trust one proxy hop (Cloud Functions / Cloud Run behind Google's LB).
|
|
67
|
+
// Setting to `true` trusts ALL proxies, allowing X-Forwarded-For spoofing.
|
|
68
|
+
app.set('trust proxy', 1);
|
|
69
|
+
// ===== SECURITY MIDDLEWARE =====
|
|
70
|
+
// Helmet for security headers (all environments)
|
|
71
|
+
app.use((0, helmet_1.default)({
|
|
72
|
+
contentSecurityPolicy: false, // Disable CSP for API
|
|
73
|
+
crossOriginEmbedderPolicy: false,
|
|
74
|
+
}));
|
|
75
|
+
// CORS
|
|
76
|
+
app.use((0, middleware_1.createCorsMiddleware)());
|
|
77
|
+
// ===== TRACKING MIDDLEWARE =====
|
|
78
|
+
// Request ID
|
|
79
|
+
app.use((0, middleware_1.requestIdMiddleware)());
|
|
80
|
+
// Request logging
|
|
81
|
+
app.use((0, middleware_1.requestLoggingMiddleware)());
|
|
82
|
+
// ===== PARSING MIDDLEWARE =====
|
|
83
|
+
// Body parsing
|
|
84
|
+
app.use(express_1.default.json({ limit: config_1.APP_CONFIG.api.requestSizeLimit }));
|
|
85
|
+
app.use(express_1.default.urlencoded({ extended: true, limit: config_1.APP_CONFIG.api.requestSizeLimit }));
|
|
86
|
+
// Input sanitization
|
|
87
|
+
app.use((0, middleware_1.sanitizeBody)());
|
|
88
|
+
// ===== RATE LIMITING =====
|
|
89
|
+
if (config_1.APP_CONFIG.app.environment !== 'development') {
|
|
90
|
+
app.use((0, middleware_1.createRateLimiter)());
|
|
91
|
+
}
|
|
92
|
+
// ===== HEALTH CHECK =====
|
|
93
|
+
app.get('/health', (_req, res) => {
|
|
94
|
+
const data = {
|
|
95
|
+
status: 'healthy',
|
|
96
|
+
timestamp: new Date().toISOString(),
|
|
97
|
+
};
|
|
98
|
+
// Only expose version/environment in non-production
|
|
99
|
+
if (config_1.APP_CONFIG.app.environment !== 'production') {
|
|
100
|
+
data.version = config_1.APP_CONFIG.app.version;
|
|
101
|
+
data.environment = config_1.APP_CONFIG.app.environment;
|
|
102
|
+
}
|
|
103
|
+
res.json({ success: true, data });
|
|
104
|
+
});
|
|
105
|
+
app.get('/health/ready', (_req, res) => {
|
|
106
|
+
// Add database connectivity check here
|
|
107
|
+
res.json({
|
|
108
|
+
success: true,
|
|
109
|
+
data: {
|
|
110
|
+
status: 'ready',
|
|
111
|
+
checks: {
|
|
112
|
+
database: 'ok',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
// ===== API ROUTES =====
|
|
118
|
+
const apiRouter = (0, express_1.Router)();
|
|
119
|
+
// Register controllers
|
|
120
|
+
if (options.controllers && options.controllers.length > 0) {
|
|
121
|
+
for (const controller of options.controllers) {
|
|
122
|
+
const basePath = controller.getBasePath();
|
|
123
|
+
const router = controller.getRouter();
|
|
124
|
+
apiRouter.use(basePath, router);
|
|
125
|
+
utils_logger_1.logger.info('Controller registered', {
|
|
126
|
+
basePath: `${config_1.APP_CONFIG.api.basePath}${basePath}`,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Mount API router
|
|
131
|
+
app.use(config_1.APP_CONFIG.api.basePath, apiRouter);
|
|
132
|
+
// ===== ERROR HANDLING =====
|
|
133
|
+
// 404 handler for unmatched routes
|
|
134
|
+
app.use((0, middleware_1.notFoundHandler)());
|
|
135
|
+
// Global error handler (must be last)
|
|
136
|
+
app.use((0, middleware_1.errorHandler)());
|
|
137
|
+
utils_logger_1.logger.info('Express application configured', {
|
|
138
|
+
environment: config_1.APP_CONFIG.app.environment,
|
|
139
|
+
basePath: config_1.APP_CONFIG.api.basePath,
|
|
140
|
+
controllers: ((_a = options.controllers) === null || _a === void 0 ? void 0 : _a.length) || 0,
|
|
141
|
+
});
|
|
142
|
+
return app;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Register controllers dynamically
|
|
146
|
+
*/
|
|
147
|
+
function registerControllers(app, controllers) {
|
|
148
|
+
const apiRouter = (0, express_1.Router)();
|
|
149
|
+
for (const controller of controllers) {
|
|
150
|
+
const basePath = controller.getBasePath();
|
|
151
|
+
const router = controller.getRouter();
|
|
152
|
+
apiRouter.use(basePath, router);
|
|
153
|
+
utils_logger_1.logger.info('Controller registered', {
|
|
154
|
+
basePath: `${config_1.APP_CONFIG.api.basePath}${basePath}`,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
// Mount API router
|
|
158
|
+
app.use(config_1.APP_CONFIG.api.basePath, apiRouter);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Start Express server (for local development)
|
|
162
|
+
*/
|
|
163
|
+
function startServer(app) {
|
|
164
|
+
const port = config_1.APP_CONFIG.app.port;
|
|
165
|
+
app.listen(port, () => {
|
|
166
|
+
utils_logger_1.logger.info('Server started', {
|
|
167
|
+
port,
|
|
168
|
+
environment: config_1.APP_CONFIG.app.environment,
|
|
169
|
+
basePath: config_1.APP_CONFIG.api.basePath,
|
|
170
|
+
});
|
|
171
|
+
console.log(`
|
|
172
|
+
╔═══════════════════════════════════════════════════════════╗
|
|
173
|
+
║ ║
|
|
174
|
+
║ 🚀 ${config_1.APP_CONFIG.app.name.padEnd(48)} ║
|
|
175
|
+
║ ║
|
|
176
|
+
║ Environment: ${config_1.APP_CONFIG.app.environment.padEnd(43)} ║
|
|
177
|
+
║ Version: ${config_1.APP_CONFIG.app.version.padEnd(43)} ║
|
|
178
|
+
║ Port: ${String(port).padEnd(43)} ║
|
|
179
|
+
║ API Path: ${config_1.APP_CONFIG.api.basePath.padEnd(43)} ║
|
|
180
|
+
║ ║
|
|
181
|
+
║ Health: http://localhost:${port}/health${' '.repeat(21)} ║
|
|
182
|
+
║ API Docs: http://localhost:${port}${config_1.APP_CONFIG.api.basePath}${' '.repeat(11)} ║
|
|
183
|
+
║ ║
|
|
184
|
+
╚═══════════════════════════════════════════════════════════╝
|
|
185
|
+
`);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/app.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AI,GAAG,mBAAU,CAAC,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;;;KAG9E,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Controller Class
|
|
3
|
+
* Handles HTTP requests and responses
|
|
4
|
+
* All controllers should extend this class
|
|
5
|
+
*/
|
|
6
|
+
import { Request, Response, NextFunction, Router } from 'express';
|
|
7
|
+
import { BaseService, RequestContext } from './BaseService';
|
|
8
|
+
import { BaseEntity } from './BaseEntity';
|
|
9
|
+
import { QueryOptions } from './BaseRepository';
|
|
10
|
+
export interface ApiResponse<T = any> {
|
|
11
|
+
success: boolean;
|
|
12
|
+
data?: T;
|
|
13
|
+
error?: {
|
|
14
|
+
code: string;
|
|
15
|
+
message: string;
|
|
16
|
+
details?: Record<string, any>;
|
|
17
|
+
};
|
|
18
|
+
metadata?: {
|
|
19
|
+
requestId: string;
|
|
20
|
+
timestamp: string;
|
|
21
|
+
version: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface PaginatedApiResponse<T = any> extends ApiResponse<T[]> {
|
|
25
|
+
pagination?: {
|
|
26
|
+
page: number;
|
|
27
|
+
pageSize: number;
|
|
28
|
+
total: number;
|
|
29
|
+
hasMore: boolean;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export declare abstract class BaseController<T extends BaseEntity> {
|
|
33
|
+
protected service: BaseService<T>;
|
|
34
|
+
protected router: Router;
|
|
35
|
+
protected basePath: string;
|
|
36
|
+
constructor(service: BaseService<T>, basePath: string);
|
|
37
|
+
/**
|
|
38
|
+
* Register routes (override in subclasses to add custom routes)
|
|
39
|
+
*/
|
|
40
|
+
protected registerRoutes(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Get router instance
|
|
43
|
+
*/
|
|
44
|
+
getRouter(): Router;
|
|
45
|
+
/**
|
|
46
|
+
* Get base path
|
|
47
|
+
*/
|
|
48
|
+
getBasePath(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Create request context from Express request
|
|
51
|
+
*/
|
|
52
|
+
protected createContext(req: Request): RequestContext;
|
|
53
|
+
/**
|
|
54
|
+
* Handle CREATE request
|
|
55
|
+
*/
|
|
56
|
+
protected handleCreate(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Handle FIND BY ID request
|
|
59
|
+
*/
|
|
60
|
+
protected handleFindById(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Handle FIND ALL request
|
|
63
|
+
*/
|
|
64
|
+
protected handleFindAll(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Handle UPDATE request
|
|
67
|
+
*/
|
|
68
|
+
protected handleUpdate(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Handle DELETE request
|
|
71
|
+
*/
|
|
72
|
+
protected handleDelete(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Parse query options from request
|
|
75
|
+
*/
|
|
76
|
+
protected parseQueryOptions(req: Request): QueryOptions;
|
|
77
|
+
/**
|
|
78
|
+
* Parse query value to appropriate type
|
|
79
|
+
*/
|
|
80
|
+
protected parseValue(value: string): any;
|
|
81
|
+
/**
|
|
82
|
+
* Send success response
|
|
83
|
+
*/
|
|
84
|
+
protected sendSuccess<D>(res: Response, data: D, status?: number, requestId?: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* Send paginated success response
|
|
87
|
+
*/
|
|
88
|
+
protected sendPaginatedSuccess<D>(res: Response, result: {
|
|
89
|
+
data: D[];
|
|
90
|
+
total: number;
|
|
91
|
+
page: number;
|
|
92
|
+
pageSize: number;
|
|
93
|
+
hasMore: boolean;
|
|
94
|
+
}, requestId?: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* Send error response
|
|
97
|
+
*/
|
|
98
|
+
protected sendError(res: Response, error: {
|
|
99
|
+
code: string;
|
|
100
|
+
message: string;
|
|
101
|
+
details?: Record<string, any>;
|
|
102
|
+
}, requestId?: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* Map error codes to HTTP status codes
|
|
105
|
+
*/
|
|
106
|
+
protected getStatusCodeFromError(code: string): number;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=BaseController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseController.d.ts","sourceRoot":"","sources":["../../../../src/base/BaseController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC/B,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,WAAW,CAAC,CAAC,EAAE,CAAC;IACrE,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MA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GAAG,EAAE,OAAO,GAAG,YAAY;IAuCvD;;OAEG;IACH,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG;IAQxC;;OAEG;IACH,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,SAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAcxF;;OAEG;IACH,SAAS,CAAC,oBAAoB,CAAC,CAAC,EAC9B,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE;QAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EACtF,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAoBP;;OAEG;IACH,SAAS,CAAC,SAAS,CACjB,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,EACvE,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAgBP;;OAEG;IACH,SAAS,CAAC,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAavD"}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base Controller Class
|
|
4
|
+
* Handles HTTP requests and responses
|
|
5
|
+
* All controllers should extend this class
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.BaseController = void 0;
|
|
9
|
+
const express_1 = require("express");
|
|
10
|
+
const utils_logger_1 = require("@xbg/utils-logger");
|
|
11
|
+
class BaseController {
|
|
12
|
+
constructor(service, basePath) {
|
|
13
|
+
this.service = service;
|
|
14
|
+
this.basePath = basePath;
|
|
15
|
+
this.router = (0, express_1.Router)();
|
|
16
|
+
this.registerRoutes();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Register routes (override in subclasses to add custom routes)
|
|
20
|
+
*/
|
|
21
|
+
registerRoutes() {
|
|
22
|
+
this.router.post('/', this.handleCreate.bind(this));
|
|
23
|
+
this.router.get('/', this.handleFindAll.bind(this));
|
|
24
|
+
this.router.get('/:id', this.handleFindById.bind(this));
|
|
25
|
+
this.router.put('/:id', this.handleUpdate.bind(this));
|
|
26
|
+
this.router.patch('/:id', this.handleUpdate.bind(this));
|
|
27
|
+
this.router.delete('/:id', this.handleDelete.bind(this));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get router instance
|
|
31
|
+
*/
|
|
32
|
+
getRouter() {
|
|
33
|
+
return this.router;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get base path
|
|
37
|
+
*/
|
|
38
|
+
getBasePath() {
|
|
39
|
+
return this.basePath;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Create request context from Express request
|
|
43
|
+
*/
|
|
44
|
+
createContext(req) {
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
return {
|
|
47
|
+
requestId: req.headers['x-request-id'] || 'unknown',
|
|
48
|
+
userId: ((_a = req.user) === null || _a === void 0 ? void 0 : _a.uid) || ((_b = req.user) === null || _b === void 0 ? void 0 : _b.id),
|
|
49
|
+
userRole: (_c = req.user) === null || _c === void 0 ? void 0 : _c.role,
|
|
50
|
+
timestamp: new Date(),
|
|
51
|
+
metadata: {
|
|
52
|
+
ip: req.ip,
|
|
53
|
+
userAgent: req.headers['user-agent'],
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Handle CREATE request
|
|
59
|
+
*/
|
|
60
|
+
async handleCreate(req, res, next) {
|
|
61
|
+
try {
|
|
62
|
+
const context = this.createContext(req);
|
|
63
|
+
utils_logger_1.logger.info('Create request received', {
|
|
64
|
+
requestId: context.requestId,
|
|
65
|
+
path: req.path,
|
|
66
|
+
});
|
|
67
|
+
const result = await this.service.create(req.body, context);
|
|
68
|
+
if (result.success && result.data) {
|
|
69
|
+
this.sendSuccess(res, result.data, 201, context.requestId);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this.sendError(res, result.error, context.requestId);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
next(error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Handle FIND BY ID request
|
|
81
|
+
*/
|
|
82
|
+
async handleFindById(req, res, next) {
|
|
83
|
+
try {
|
|
84
|
+
const context = this.createContext(req);
|
|
85
|
+
const { id } = req.params;
|
|
86
|
+
utils_logger_1.logger.debug('Find by ID request received', {
|
|
87
|
+
requestId: context.requestId,
|
|
88
|
+
id,
|
|
89
|
+
});
|
|
90
|
+
const result = await this.service.findById(id, context);
|
|
91
|
+
if (result.success && result.data) {
|
|
92
|
+
this.sendSuccess(res, result.data, 200, context.requestId);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this.sendError(res, result.error, context.requestId);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
next(error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Handle FIND ALL request
|
|
104
|
+
*/
|
|
105
|
+
async handleFindAll(req, res, next) {
|
|
106
|
+
try {
|
|
107
|
+
const context = this.createContext(req);
|
|
108
|
+
utils_logger_1.logger.debug('Find all request received', {
|
|
109
|
+
requestId: context.requestId,
|
|
110
|
+
query: req.query,
|
|
111
|
+
});
|
|
112
|
+
// Parse query options
|
|
113
|
+
const options = this.parseQueryOptions(req);
|
|
114
|
+
// Check if pagination is requested
|
|
115
|
+
const page = parseInt(req.query.page);
|
|
116
|
+
const pageSize = parseInt(req.query.pageSize) || 20;
|
|
117
|
+
if (page && page > 0) {
|
|
118
|
+
const result = await this.service.findPaginated(page, pageSize, options, context);
|
|
119
|
+
if (result.success && result.data) {
|
|
120
|
+
this.sendPaginatedSuccess(res, result.data, context.requestId);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.sendError(res, result.error, context.requestId);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const result = await this.service.findAll(options, context);
|
|
128
|
+
if (result.success && result.data) {
|
|
129
|
+
this.sendSuccess(res, result.data, 200, context.requestId);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
this.sendError(res, result.error, context.requestId);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
next(error);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Handle UPDATE request
|
|
142
|
+
*/
|
|
143
|
+
async handleUpdate(req, res, next) {
|
|
144
|
+
try {
|
|
145
|
+
const context = this.createContext(req);
|
|
146
|
+
const { id } = req.params;
|
|
147
|
+
utils_logger_1.logger.info('Update request received', {
|
|
148
|
+
requestId: context.requestId,
|
|
149
|
+
id,
|
|
150
|
+
});
|
|
151
|
+
const result = await this.service.update(id, req.body, context);
|
|
152
|
+
if (result.success && result.data) {
|
|
153
|
+
this.sendSuccess(res, result.data, 200, context.requestId);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
this.sendError(res, result.error, context.requestId);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
next(error);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Handle DELETE request
|
|
165
|
+
*/
|
|
166
|
+
async handleDelete(req, res, next) {
|
|
167
|
+
try {
|
|
168
|
+
const context = this.createContext(req);
|
|
169
|
+
const { id } = req.params;
|
|
170
|
+
const hardDelete = req.query.hard === 'true';
|
|
171
|
+
utils_logger_1.logger.info('Delete request received', {
|
|
172
|
+
requestId: context.requestId,
|
|
173
|
+
id,
|
|
174
|
+
hardDelete,
|
|
175
|
+
});
|
|
176
|
+
const result = await this.service.delete(id, context, hardDelete);
|
|
177
|
+
if (result.success) {
|
|
178
|
+
this.sendSuccess(res, { message: 'Deleted successfully' }, 200, context.requestId);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.sendError(res, result.error, context.requestId);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
next(error);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Parse query options from request
|
|
190
|
+
*/
|
|
191
|
+
parseQueryOptions(req) {
|
|
192
|
+
const options = {};
|
|
193
|
+
// Parse limit
|
|
194
|
+
if (req.query.limit) {
|
|
195
|
+
options.limit = parseInt(req.query.limit);
|
|
196
|
+
}
|
|
197
|
+
// Parse offset
|
|
198
|
+
if (req.query.offset) {
|
|
199
|
+
options.offset = parseInt(req.query.offset);
|
|
200
|
+
}
|
|
201
|
+
// Parse orderBy
|
|
202
|
+
if (req.query.orderBy) {
|
|
203
|
+
const orderByStr = req.query.orderBy;
|
|
204
|
+
options.orderBy = orderByStr.split(',').map((field) => {
|
|
205
|
+
const [name, direction = 'asc'] = field.split(':');
|
|
206
|
+
return { field: name, direction: direction };
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// Parse where clauses (basic implementation)
|
|
210
|
+
// Expected format: ?where=field:operator:value
|
|
211
|
+
if (req.query.where) {
|
|
212
|
+
const whereStr = Array.isArray(req.query.where) ? req.query.where : [req.query.where];
|
|
213
|
+
options.where = whereStr.map((clause) => {
|
|
214
|
+
const [field, operator, value] = clause.split(':');
|
|
215
|
+
return {
|
|
216
|
+
field,
|
|
217
|
+
operator: operator,
|
|
218
|
+
value: this.parseValue(value),
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return options;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Parse query value to appropriate type
|
|
226
|
+
*/
|
|
227
|
+
parseValue(value) {
|
|
228
|
+
if (value === 'null')
|
|
229
|
+
return null;
|
|
230
|
+
if (value === 'true')
|
|
231
|
+
return true;
|
|
232
|
+
if (value === 'false')
|
|
233
|
+
return false;
|
|
234
|
+
if (!isNaN(Number(value)))
|
|
235
|
+
return Number(value);
|
|
236
|
+
return value;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Send success response
|
|
240
|
+
*/
|
|
241
|
+
sendSuccess(res, data, status = 200, requestId) {
|
|
242
|
+
const response = {
|
|
243
|
+
success: true,
|
|
244
|
+
data,
|
|
245
|
+
metadata: {
|
|
246
|
+
requestId: requestId || 'unknown',
|
|
247
|
+
timestamp: new Date().toISOString(),
|
|
248
|
+
version: '1.0.0',
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
res.status(status).json(response);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Send paginated success response
|
|
255
|
+
*/
|
|
256
|
+
sendPaginatedSuccess(res, result, requestId) {
|
|
257
|
+
const response = {
|
|
258
|
+
success: true,
|
|
259
|
+
data: result.data,
|
|
260
|
+
pagination: {
|
|
261
|
+
page: result.page,
|
|
262
|
+
pageSize: result.pageSize,
|
|
263
|
+
total: result.total,
|
|
264
|
+
hasMore: result.hasMore,
|
|
265
|
+
},
|
|
266
|
+
metadata: {
|
|
267
|
+
requestId: requestId || 'unknown',
|
|
268
|
+
timestamp: new Date().toISOString(),
|
|
269
|
+
version: '1.0.0',
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
res.status(200).json(response);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Send error response
|
|
276
|
+
*/
|
|
277
|
+
sendError(res, error, requestId) {
|
|
278
|
+
const statusCode = this.getStatusCodeFromError(error.code);
|
|
279
|
+
const response = {
|
|
280
|
+
success: false,
|
|
281
|
+
error,
|
|
282
|
+
metadata: {
|
|
283
|
+
requestId: requestId || 'unknown',
|
|
284
|
+
timestamp: new Date().toISOString(),
|
|
285
|
+
version: '1.0.0',
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
res.status(statusCode).json(response);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Map error codes to HTTP status codes
|
|
292
|
+
*/
|
|
293
|
+
getStatusCodeFromError(code) {
|
|
294
|
+
const statusMap = {
|
|
295
|
+
NOT_FOUND: 404,
|
|
296
|
+
FORBIDDEN: 403,
|
|
297
|
+
UNAUTHORIZED: 401,
|
|
298
|
+
VALIDATION_ERROR: 400,
|
|
299
|
+
CONFLICT: 409,
|
|
300
|
+
INTERNAL_ERROR: 500,
|
|
301
|
+
UNKNOWN_ERROR: 500,
|
|
302
|
+
};
|
|
303
|
+
return statusMap[code] || 500;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
exports.BaseController = BaseController;
|
|
307
|
+
//# sourceMappingURL=BaseController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseController.js","sourceRoot":"","sources":["../../../../src/base/BaseController.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,qCAAkE;AAGlE,oDAA2C;AA2B3C,MAAsB,cAAc;IAKlC,YAAY,OAAuB,EAAE,QAAgB;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAC;QACvB,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACO,cAAc;QACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACpD,I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