@thisisagile/easy
Version:
Straightforward library for building domain-driven microservice architectures
15 lines (11 loc) • 516 B
text/typescript
import { isA } from './IsA';
import { Text } from './Text';
import { ctx } from './Context';
import { TypeGuard } from './TypeGuard';
export type Result = { message: string; location?: string; domain?: string };
export const toResult = (message: Text, location?: Text, domain: Text = ctx.env.domain): Result => ({
message: message.toString(),
location: location?.toString(),
domain: domain?.toString(),
});
export const isResult: TypeGuard<Result> = (r?: unknown): r is Result => isA<Result>(r, 'message');