@dudousxd/nestjs-diagnostics
Version:
A standard convention for @dudousxd/nestjs-* libs to emit observability events over node:diagnostics_channel.
13 lines • 746 B
JavaScript
const ROLES = ['all', 'api', 'worker'];
/** Validate `role` (default `'all'`) and refuse combinations that cannot work. */
export function resolveRole(role, transport) {
const resolved = role ?? 'all';
if (!ROLES.includes(resolved)) {
throw new Error(`@dudousxd/nestjs-diagnostics: role must be 'all', 'api' or 'worker' (got ${JSON.stringify(role)})`);
}
if (resolved !== 'all' && !transport) {
throw new Error(`@dudousxd/nestjs-diagnostics: role is "${resolved}", which splits emitting from consuming, but no \`default\` transport is selected, so nothing carries events between the two halves. Select a transport with \`default\`, or drop \`role\`.`);
}
return resolved;
}
//# sourceMappingURL=role.js.map