server-helpers.ts15 lines · main
| 1 | /** |
| 2 | * Identity-function wrappers that document intent on the author side |
| 3 | * and give us a future enforcement hook (e.g. read-only transactions |
| 4 | * on `query`). The runtime infers query/mutation/action from where |
| 5 | * the file lives on disk today, not from these wrappers — but |
| 6 | * declaring intent in source keeps the author-side story clear and |
| 7 | * matches Convex's `query(async (ctx, args) => {...})` shape. |
| 8 | */ |
| 9 | import type { Ctx } from '@briven/schema'; |
| 10 | |
| 11 | type FnOf<TArgs, TOut> = (ctx: Ctx, args: TArgs) => Promise<TOut> | TOut; |
| 12 | |
| 13 | export const query = <TArgs, TOut>(fn: FnOf<TArgs, TOut>): FnOf<TArgs, TOut> => fn; |
| 14 | export const mutation = <TArgs, TOut>(fn: FnOf<TArgs, TOut>): FnOf<TArgs, TOut> => fn; |
| 15 | export const action = <TArgs, TOut>(fn: FnOf<TArgs, TOut>): FnOf<TArgs, TOut> => fn; |