- ✅ Ticket 1.1: Estructura Clean Architecture en backend - ✅ Ticket 1.2: Schemas Zod compartidos - ✅ Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares) - ✅ Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares) - ✅ Ticket 1.5: Eliminación de duplicidades (~50 líneas) Cambios principales: - Creada estructura Clean Architecture en backend/src/ - Schemas Zod compartidos en backend/src/shared/schemas/ - Refactorización modular de drugs y procedures - Utilidades genéricas en src/utils/ (filter, validation) - Eliminados scripts obsoletos y documentación antigua - Corregidos errores: QueryClient, import test-error-handling - Build verificado y funcionando correctamente
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const utils_1 = require("./utils");
|
|
function throwLater(e) {
|
|
setTimeout(function () {
|
|
throw e;
|
|
}, 0);
|
|
}
|
|
function asCallback(promise, nodeback, options) {
|
|
if (typeof nodeback === "function") {
|
|
promise.then((val) => {
|
|
let ret;
|
|
if (options !== undefined &&
|
|
Object(options).spread &&
|
|
Array.isArray(val)) {
|
|
ret = utils_1.tryCatch(nodeback).apply(undefined, [null].concat(val));
|
|
}
|
|
else {
|
|
ret =
|
|
val === undefined
|
|
? utils_1.tryCatch(nodeback)(null)
|
|
: utils_1.tryCatch(nodeback)(null, val);
|
|
}
|
|
if (ret === utils_1.errorObj) {
|
|
throwLater(ret.e);
|
|
}
|
|
}, (cause) => {
|
|
if (!cause) {
|
|
const newReason = new Error(cause + "");
|
|
Object.assign(newReason, { cause });
|
|
cause = newReason;
|
|
}
|
|
const ret = utils_1.tryCatch(nodeback)(cause);
|
|
if (ret === utils_1.errorObj) {
|
|
throwLater(ret.e);
|
|
}
|
|
});
|
|
}
|
|
return promise;
|
|
}
|
|
exports.default = asCallback;
|