refactor(auth): auth, passkey, profile, token and admin services refuse with DomainError instead of returning error envelopes

This commit is contained in:
Maurice
2026-10-10 15:12:44 +02:00
parent 66042ae1c7
commit e81efcbc57
24 changed files with 460 additions and 516 deletions
+20
View File
@@ -0,0 +1,20 @@
import { DomainError } from '../../src/nest/common/domain-error';
/**
* Awaits a service call and hands a `DomainError` refusal back as the
* `{ error, status }` result the service used to return, so a test can assert a
* refusal and a success through one shape. Any other rejection propagates.
*/
export async function asLegacyResult<T>(call: Promise<T> | T): Promise<T & { error?: string; status?: number }> {
try {
return (await call) as T & { error?: string; status?: number };
} catch (err) {
if (err instanceof DomainError) {
return { ...err.details, error: err.publicMessage, status: err.getStatus() } as T & {
error?: string;
status?: number;
};
}
throw err;
}
}