feat(apihits): added in api hits to monitor and assist for issues
This commit is contained in:
35
app/src/pkg/db/schema/apiHits.ts
Normal file
35
app/src/pkg/db/schema/apiHits.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
integer,
|
||||
jsonb,
|
||||
pgTable,
|
||||
text,
|
||||
timestamp,
|
||||
uniqueIndex,
|
||||
uuid,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { createSelectSchema } from "drizzle-zod";
|
||||
|
||||
export const apiHits = pgTable(
|
||||
"apiHits",
|
||||
{
|
||||
apiHit_id: uuid("apiHit_id").defaultRandom().primaryKey(),
|
||||
method: text("method").notNull(),
|
||||
path: text("path").notNull(),
|
||||
body: jsonb("body"),
|
||||
status: integer("status"),
|
||||
ip: text("ip"),
|
||||
duration: integer("duration"),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
},
|
||||
(table) => [
|
||||
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
|
||||
// uniqueIndex("endpoint").on(table.endpoint, table.ip),
|
||||
]
|
||||
);
|
||||
|
||||
// Schema for inserting a user - can be used to validate API requests
|
||||
// export const insertRolesSchema = createInsertSchema(roles, {
|
||||
// name: z.string().min(3, {message: "Role name must be more than 3 letters"}),
|
||||
// });
|
||||
// Schema for selecting a Expenses - can be used to validate API responses
|
||||
export const selectRolesSchema = createSelectSchema(apiHits);
|
||||
Reference in New Issue
Block a user