Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. π« Status page with uptime monitoring & API monitoring as code π« openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
834 B Β· 28 lines
TypeScript
1234567891011121314151617181920212223242526272829import { and, db as defaultDb, eq, isNull } from "@openstatus/db";import { user } from "@openstatus/db/src/schema";
import type { ServiceContext } from "../context";import { GetUserInput } from "./schemas";
export type UserRecord = typeof user.$inferSelect;
/** * Load an active (non-soft-deleted) user by id. Returns `undefined` when * the user doesn't exist or is soft-deleted β matches the legacy router * which surfaced the raw lookup result to the client. */export async function getUser(args: { ctx: ServiceContext; input: GetUserInput;}): Promise<UserRecord | undefined> { const input = GetUserInput.parse(args.input); const db = args.ctx.db ?? defaultDb;
const row = await db .select() .from(user) .where(and(eq(user.id, input.userId), isNull(user.deletedAt))) .get();
return row;}