@hemia/core 0.0.1 → 0.0.3
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/README.md +17 -0
- package/dist/hemia-core.esm.js +22 -0
- package/dist/hemia-core.js +22 -0
- package/dist/types/hemia-factory.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,10 @@ Paquete generado con [Hemia CLI](https://www.npmjs.com/package/@hemia/cli)
|
|
|
12
12
|
npm install @hemia/hemia-core
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
```bash
|
|
16
|
+
bun add @hemia/hemia-core
|
|
17
|
+
```
|
|
18
|
+
|
|
15
19
|
---
|
|
16
20
|
|
|
17
21
|
## 🛠️ Scripts disponibles
|
|
@@ -32,5 +36,18 @@ npm install @hemia/hemia-core
|
|
|
32
36
|
|
|
33
37
|
---
|
|
34
38
|
|
|
39
|
+
## 🚀 Funciones y Clases Exportadas
|
|
40
|
+
|
|
41
|
+
| Nombre | Tipo | Descripción breve |
|
|
42
|
+
|-------------------------|---------|-------------------|
|
|
43
|
+
| `HemiaFactory` | Clase | Inicializa la app Hemia conectando Express con Inversify y registra controladores. |
|
|
44
|
+
| `ResponseSerializer` | Clase | Transforma entidades a DTO usando class-transformer. |
|
|
45
|
+
| `GuardsConsumer` | Clase | Ejecuta guards secuencialmente y lanza error si alguno falla. |
|
|
46
|
+
| `AuthGuard` | Clase | Guard de autenticación y autorización basado en roles/permisos. |
|
|
47
|
+
| `HemiaExecutionContext` | Clase | Contexto de ejecución para requests HTTP, accede a argumentos y request/response. |
|
|
48
|
+
| `Reflector` | Clase | Utilidad para obtener metadata de clases y métodos (roles, permisos, etc). |
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
35
52
|
## ✨ Generado con Hemia CLI
|
|
36
53
|
|
package/dist/hemia-core.esm.js
CHANGED
|
@@ -261,6 +261,28 @@ class HemiaFactory {
|
|
|
261
261
|
const app = express();
|
|
262
262
|
app.use(express.json());
|
|
263
263
|
app.use(express.urlencoded({ extended: true }));
|
|
264
|
+
if (options.middlewares && Array.isArray(options.middlewares)) {
|
|
265
|
+
options.middlewares.forEach(middleware => {
|
|
266
|
+
app.use(middleware);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
app.use((req, res, next) => {
|
|
270
|
+
const defaultHeaders = {
|
|
271
|
+
'Access-Control-Allow-Origin': req.headers.origin || '*',
|
|
272
|
+
'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,PATCH,OPTIONS',
|
|
273
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Api-Key, Language, X-No-Cookies, x-session',
|
|
274
|
+
'Access-Control-Allow-Credentials': 'true',
|
|
275
|
+
'Access-Control-Expose-Headers': 'Authorization, X-Correlation-Id, X-Trace-Id, x-session',
|
|
276
|
+
};
|
|
277
|
+
const headers = { ...defaultHeaders, ...(options.corsHeaders || {}) };
|
|
278
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
279
|
+
res.header(key, value);
|
|
280
|
+
});
|
|
281
|
+
if (req.method === 'OPTIONS') {
|
|
282
|
+
return res.sendStatus(200);
|
|
283
|
+
}
|
|
284
|
+
next();
|
|
285
|
+
});
|
|
264
286
|
if (!container.isBound(Reflector)) {
|
|
265
287
|
container.bind(Reflector).toSelf().inSingletonScope();
|
|
266
288
|
}
|
package/dist/hemia-core.js
CHANGED
|
@@ -263,6 +263,28 @@ class HemiaFactory {
|
|
|
263
263
|
const app = express();
|
|
264
264
|
app.use(express.json());
|
|
265
265
|
app.use(express.urlencoded({ extended: true }));
|
|
266
|
+
if (options.middlewares && Array.isArray(options.middlewares)) {
|
|
267
|
+
options.middlewares.forEach(middleware => {
|
|
268
|
+
app.use(middleware);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
app.use((req, res, next) => {
|
|
272
|
+
const defaultHeaders = {
|
|
273
|
+
'Access-Control-Allow-Origin': req.headers.origin || '*',
|
|
274
|
+
'Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,PATCH,OPTIONS',
|
|
275
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Api-Key, Language, X-No-Cookies, x-session',
|
|
276
|
+
'Access-Control-Allow-Credentials': 'true',
|
|
277
|
+
'Access-Control-Expose-Headers': 'Authorization, X-Correlation-Id, X-Trace-Id, x-session',
|
|
278
|
+
};
|
|
279
|
+
const headers = { ...defaultHeaders, ...(options.corsHeaders || {}) };
|
|
280
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
281
|
+
res.header(key, value);
|
|
282
|
+
});
|
|
283
|
+
if (req.method === 'OPTIONS') {
|
|
284
|
+
return res.sendStatus(200);
|
|
285
|
+
}
|
|
286
|
+
next();
|
|
287
|
+
});
|
|
266
288
|
if (!container.isBound(exports.Reflector)) {
|
|
267
289
|
container.bind(exports.Reflector).toSelf().inSingletonScope();
|
|
268
290
|
}
|