Files
promo_steakhouse/src/lib/staff.ts
T
lukas 4ed5bc47f6
CI / test (push) Successful in 5m3s
CI / build (push) Successful in 2m41s
CI / deploy (push) Successful in 17s
✨ first version
2026-08-28 09:49:01 +02:00

20 lines
850 B
TypeScript

import { createServerFn } from '@tanstack/react-start'
export const listStaffMembers = createServerFn({ method: 'GET' }).handler(async () => {
const [{ getAuth }, { getRequest }] = await Promise.all([
import('#/lib/auth-instance'),
import('@tanstack/react-start/server'),
])
const { users } = await getAuth().api.listUsers({
headers: getRequest().headers,
query: { sortBy: 'createdAt', sortDirection: 'asc', limit: 100 },
})
// `listUsers`'s return type doesn't pick up `user.additionalFields` from the
// auth config the way the actual response body does — `phone` is present at
// runtime (Better Auth includes every configured additional field on every
// user-returning endpoint) but missing from admin.d.ts's `UserWithRole` type.
return users as Array<(typeof users)[number] & { phone: string | null }>
})