UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

50 lines (48 loc) • 1.39 kB
import { MISSING_CONFIG_MESSAGE, findConfigPath } from "../services/resolution/load.mjs"; import { DbOpsService } from "../services/db/ops.mjs"; //#region src/handlers/db.ts function missingConfig() { return `${MISSING_CONFIG_MESSAGE} in current directory`; } function registerDb(builder) { return { dbStudio: builder.dbStudio.effect(function* (_opts, input) { if (!findConfigPath()) return { status: "error", plugin: input.plugin, source: "remote", section: "", error: missingConfig() }; return yield* (yield* DbOpsService).studio(input.plugin); }), dbDoctor: builder.dbDoctor.effect(function* (_opts, input) { if (!findConfigPath()) return { status: "error", plugin: input.plugin, slug: "", journalTable: "", journalSchema: "", diagnosis: "error", localMigrationCount: 0, appliedHashCount: 0, expectedTables: [], missingTables: [], error: missingConfig() }; return yield* (yield* DbOpsService).doctor(input.plugin); }), dbRepair: builder.dbRepair.effect(function* (_opts, input) { if (!findConfigPath()) return { status: "error", message: MISSING_CONFIG_MESSAGE, diagnosis: null, error: "No config" }; return yield* (yield* DbOpsService).repair(input.plugin, input.mode ?? "history-reset"); }) }; } //#endregion export { registerDb }; //# sourceMappingURL=db.mjs.map