everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
62 lines (60 loc) • 1.98 kB
JavaScript
import { MISSING_CONFIG_MESSAGE, readAuthoredConfigInput } from "../services/resolution/load.mjs";
import { resolvePublishedConfig } from "../services/registry/published.mjs";
import { verifyPublishedPins, verifyReleaseFreshness } from "../services/deploy/verify.mjs";
import { Effect } from "effect";
//#region src/handlers/verify.ts
function registerVerify(builder) {
return { verify: builder.verify.effect(function* (_opts, input) {
return yield* Effect.promise(async () => {
let authored = null;
try {
authored = await readAuthoredConfigInput();
} catch (error) {
return {
status: "fail",
remotes: [],
error: error instanceof Error ? error.message : String(error)
};
}
if (!authored) {
const account = process.env.BOS_ACCOUNT;
const gateway = process.env.BOS_GATEWAY;
if (!account || !gateway) return {
status: "fail",
remotes: [],
error: MISSING_CONFIG_MESSAGE
};
try {
authored = await resolvePublishedConfig(account, gateway);
} catch (error) {
return {
status: "fail",
remotes: [],
error: error instanceof Error ? error.message : String(error)
};
}
if (!authored) return {
status: "fail",
remotes: [],
error: `No config found at bos://${account}/${gateway} — verify BOS_ACCOUNT/BOS_GATEWAY and that the config has been published.`
};
}
const config = authored;
const report = await verifyPublishedPins({ config });
const freshness = await verifyReleaseFreshness({
config,
...input.registry ? { registry: input.registry } : {}
});
const rot = report.remotes.some((remote) => !remote.manifestOk || remote.mismatches.length > 0);
const behind = freshness?.behind === true;
return {
status: rot ? "fail" : behind ? "drift" : "ok",
remotes: report.remotes,
...freshness ? { freshness } : {}
};
});
}) };
}
//#endregion
export { registerVerify };
//# sourceMappingURL=verify.mjs.map