chore: scaffold turbo monorepo with hono api and react admin web
This commit is contained in:
10
packages/shared/src/result.ts
Normal file
10
packages/shared/src/result.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Result pattern shared by all use cases.
|
||||
* Use cases return `Result` instead of throwing for expected outcomes.
|
||||
*/
|
||||
export type Ok<T> = { ok: true; value: T }
|
||||
export type Failure<E> = { ok: false; error: E }
|
||||
export type Result<T, E> = Ok<T> | Failure<E>
|
||||
|
||||
export const Ok = <T>(value: T): Ok<T> => ({ ok: true, value })
|
||||
export const Failure = <E>(error: E): Failure<E> => ({ ok: false, error })
|
||||
Reference in New Issue
Block a user