Plantillas y su script
This commit is contained in:
parent
2c695ee8a6
commit
f8b45618ab
@ -22,4 +22,6 @@ JWT_ACCESS_EXPIRATION=1h
|
|||||||
JWT_REFRESH_EXPIRATION=7d
|
JWT_REFRESH_EXPIRATION=7d
|
||||||
|
|
||||||
|
|
||||||
PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome
|
PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome
|
||||||
|
|
||||||
|
TEMPLATES_PATH=/home/rodax/Documentos/uecko-erp/modules
|
||||||
@ -35,13 +35,6 @@ DB_SYNC_MODE=alter # none | alter | force
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ───────────────────────────────
|
|
||||||
# Logging de la app
|
|
||||||
# ───────────────────────────────
|
|
||||||
LOG_LEVEL=info # error | warn | info | debug
|
|
||||||
LOG_JSON=false # true para logs en JSON (entornos con agregadores)
|
|
||||||
|
|
||||||
|
|
||||||
# ───────────────────────────────
|
# ───────────────────────────────
|
||||||
# Warmup por módulo
|
# Warmup por módulo
|
||||||
# ───────────────────────────────
|
# ───────────────────────────────
|
||||||
@ -61,4 +54,10 @@ JWT_REFRESH_EXPIRATION=7d
|
|||||||
# ───────────────────────────────
|
# ───────────────────────────────
|
||||||
# Otros
|
# Otros
|
||||||
# ───────────────────────────────
|
# ───────────────────────────────
|
||||||
PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome
|
PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome
|
||||||
|
|
||||||
|
|
||||||
|
# ───────────────────────────────
|
||||||
|
# Plantillas
|
||||||
|
# ───────────────────────────────
|
||||||
|
TEMPLATES_PATH=/opt/factuges/templates
|
||||||
@ -34,4 +34,6 @@ JWT_SECRET=supersecretkey
|
|||||||
JWT_ACCESS_EXPIRATION=1h
|
JWT_ACCESS_EXPIRATION=1h
|
||||||
JWT_REFRESH_EXPIRATION=7d
|
JWT_REFRESH_EXPIRATION=7d
|
||||||
|
|
||||||
PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome
|
PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome
|
||||||
|
|
||||||
|
TEMPLATES_PATH=/opt/factuges/templates
|
||||||
@ -40,6 +40,9 @@ const DB_SYNC_MODE =
|
|||||||
// Opcional: timezone para Sequelize (según necesidades)
|
// Opcional: timezone para Sequelize (según necesidades)
|
||||||
const APP_TIMEZONE = process.env.APP_TIMEZONE ?? "Europe/Madrid";
|
const APP_TIMEZONE = process.env.APP_TIMEZONE ?? "Europe/Madrid";
|
||||||
|
|
||||||
|
// Ruta raíz para plantillas (templates)
|
||||||
|
const TEMPLATES_PATH = process.env.TEMPLATES_PATH ?? "./templates";
|
||||||
|
|
||||||
// Proxy (no usáis ahora, pero dejamos la variable por si se activa en el futuro)
|
// Proxy (no usáis ahora, pero dejamos la variable por si se activa en el futuro)
|
||||||
const TRUST_PROXY = asNumber(process.env.TRUST_PROXY, 0);
|
const TRUST_PROXY = asNumber(process.env.TRUST_PROXY, 0);
|
||||||
|
|
||||||
@ -59,6 +62,7 @@ export const ENV = {
|
|||||||
DB_SYNC_MODE,
|
DB_SYNC_MODE,
|
||||||
APP_TIMEZONE,
|
APP_TIMEZONE,
|
||||||
TRUST_PROXY,
|
TRUST_PROXY,
|
||||||
|
TEMPLATES_PATH,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const Flags = {
|
export const Flags = {
|
||||||
|
|||||||
@ -227,13 +227,21 @@ process.on("uncaughtException", async (error: Error) => {
|
|||||||
logger.info(`DB_LOGGING: ${ENV.DB_LOGGING}`);
|
logger.info(`DB_LOGGING: ${ENV.DB_LOGGING}`);
|
||||||
logger.info(`DB_SYNC_MODE: ${ENV.DB_SYNC_MODE}`);
|
logger.info(`DB_SYNC_MODE: ${ENV.DB_SYNC_MODE}`);
|
||||||
|
|
||||||
|
logger.info(`TEMPLATES_PATH: ${ENV.TEMPLATES_PATH}`);
|
||||||
|
|
||||||
const database = await tryConnectToDatabase();
|
const database = await tryConnectToDatabase();
|
||||||
|
|
||||||
// Lógica de inicialización de DB, si procede:
|
// Lógica de inicialización de DB, si procede:
|
||||||
// initStructure(sequelizeConn.connection);
|
// initStructure(sequelizeConn.connection);
|
||||||
// insertUsers();
|
// insertUsers();
|
||||||
|
|
||||||
await initModules({ app, database, baseRoutePath: API_BASE_PATH, logger });
|
await initModules({
|
||||||
|
app,
|
||||||
|
database,
|
||||||
|
baseRoutePath: API_BASE_PATH,
|
||||||
|
logger,
|
||||||
|
templateRootPath: ENV.TEMPLATES_PATH,
|
||||||
|
});
|
||||||
|
|
||||||
// El servidor ya está listo para recibir tráfico
|
// El servidor ya está listo para recibir tráfico
|
||||||
isReady = true;
|
isReady = true;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import { IModuleServer, ModuleParams } from "@erp/core/api";
|
import type { IModuleServer, ModuleParams } from "@erp/core/api";
|
||||||
|
|
||||||
import { logger } from "../logger";
|
import { logger } from "../logger";
|
||||||
|
|
||||||
import { initModels, registerModels } from "./model-loader";
|
import { initModels, registerModels } from "./model-loader";
|
||||||
import { getService, listServices, registerService } from "./service-registry";
|
import { getService, listServices, registerService } from "./service-registry";
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import customerInvoicesAPIModule from "@erp/customer-invoices/api";
|
import customerInvoicesAPIModule from "@erp/customer-invoices/api";
|
||||||
import customersAPIModule from "@erp/customers/api";
|
import customersAPIModule from "@erp/customers/api";
|
||||||
|
|
||||||
//import verifactuAPIModule from "@erp/verifactu/api";
|
//import verifactuAPIModule from "@erp/verifactu/api";
|
||||||
|
|
||||||
import { registerModule } from "./lib";
|
import { registerModule } from "./lib";
|
||||||
|
|||||||
@ -8,6 +8,8 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "turbo build",
|
"build": "turbo build",
|
||||||
|
"build:templates": "bash scripts/build-templates.sh",
|
||||||
|
"build:api": "bash scripts/build-api.sh rodax --api",
|
||||||
"dev": "turbo dev",
|
"dev": "turbo dev",
|
||||||
"dev:server": "turbo dev --filter=server",
|
"dev:server": "turbo dev --filter=server",
|
||||||
"dev:client": "turbo dev --filter=client",
|
"dev:client": "turbo dev --filter=client",
|
||||||
|
|||||||
31
scripts/build-templates.sh
Executable file
31
scripts/build-templates.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Fail fast
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Root directory (dir where the script lives, then go up)
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
|
||||||
|
SOURCE_DIR="$ROOT_DIR/modules"
|
||||||
|
TARGET_DIR="$ROOT_DIR/apps/server/dist/templates"
|
||||||
|
|
||||||
|
echo "[build-templates] Root: $ROOT_DIR"
|
||||||
|
echo "[build-templates] Source: $SOURCE_DIR"
|
||||||
|
echo "[build-templates] Target: $TARGET_DIR"
|
||||||
|
|
||||||
|
# Ensure target directory exists and is empty
|
||||||
|
rm -rf "$TARGET_DIR"
|
||||||
|
mkdir -p "$TARGET_DIR"
|
||||||
|
|
||||||
|
# Loop through each package
|
||||||
|
for module in "$SOURCE_DIR"/*; do
|
||||||
|
if [ -d "$module/templates" ]; then
|
||||||
|
module_name=$(basename "$module")
|
||||||
|
echo "→ Copying templates for module: $module_name"
|
||||||
|
|
||||||
|
mkdir -p "$TARGET_DIR/$module_name"
|
||||||
|
cp -R "$module/templates/." "$TARGET_DIR/$module_name/"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[build-templates] Completed."
|
||||||
@ -17,6 +17,10 @@
|
|||||||
"inputs": ["$TURBO_DEFAULT$", ".env*"],
|
"inputs": ["$TURBO_DEFAULT$", ".env*"],
|
||||||
"outputs": ["dist/**"]
|
"outputs": ["dist/**"]
|
||||||
},
|
},
|
||||||
|
"build:templates": {
|
||||||
|
"dependsOn": [],
|
||||||
|
"outputs": ["dist/templates/**"]
|
||||||
|
},
|
||||||
"clean": {
|
"clean": {
|
||||||
"cache": false
|
"cache": false
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user