feat(platform): add Discord onboarding and Velocity gate
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
||||
import * as schema from "./schema";
|
||||
import { events } from "./schema";
|
||||
|
||||
type Database = PostgresJsDatabase<typeof schema>;
|
||||
|
||||
export interface RecordEventInput {
|
||||
type: string;
|
||||
source: string;
|
||||
subject?: string;
|
||||
data?: Record<string, unknown>;
|
||||
actorUserId?: string;
|
||||
ipAddress?: string;
|
||||
correlationId?: string;
|
||||
time?: Date;
|
||||
}
|
||||
|
||||
export async function recordEvent(db: Database, input: RecordEventInput) {
|
||||
const id = randomUUID();
|
||||
await db.insert(events).values({
|
||||
id,
|
||||
specVersion: "1.0",
|
||||
source: input.source,
|
||||
type: input.type,
|
||||
subject: input.subject,
|
||||
time: input.time ?? new Date(),
|
||||
dataContentType: "application/json",
|
||||
data: input.data ?? {},
|
||||
actorUserId: input.actorUserId,
|
||||
ipAddress: input.ipAddress,
|
||||
correlationId: input.correlationId,
|
||||
});
|
||||
return id;
|
||||
}
|
||||
Reference in New Issue
Block a user