feat(apihits): so i can see if what end points are being used and when and how often

This commit is contained in:
2025-05-15 20:55:17 -05:00
parent 12ea23c9fb
commit 9d9a2683fa
86 changed files with 15710 additions and 496 deletions

View File

@@ -0,0 +1,11 @@
CREATE TABLE "apiHits" (
"ip" text,
"endpoint" text,
"action" text,
"lastBody" text,
"stats" text,
"add_date" timestamp DEFAULT now(),
"upd_date" timestamp DEFAULT now()
);
--> statement-breakpoint
CREATE UNIQUE INDEX "endpoint" ON "apiHits" USING btree ("endpoint","ip");

View File

@@ -0,0 +1 @@
ALTER TABLE "apiHits" ADD COLUMN "apiHit_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL;

View File

@@ -0,0 +1 @@
ALTER TABLE "apiHits" ALTER COLUMN "stats" SET DATA TYPE integer;

View File

@@ -0,0 +1 @@
ALTER TABLE "apiHits" DROP COLUMN "stats";

View File

@@ -0,0 +1 @@
ALTER TABLE "apiHits" ADD COLUMN "stats" integer;

View File

@@ -0,0 +1 @@
ALTER TABLE "apiHits" ALTER COLUMN "stats" SET DEFAULT 1;

View File

@@ -0,0 +1 @@
ALTER TABLE "apiHits" DROP COLUMN "lastBody";

View File

@@ -0,0 +1 @@
ALTER TABLE "apiHits" ADD COLUMN "lastBody" jsonb;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -372,6 +372,62 @@
"when": 1744685129838,
"tag": "0052_dark_human_torch",
"breakpoints": true
},
{
"idx": 53,
"version": "7",
"when": 1747355241210,
"tag": "0053_short_colleen_wing",
"breakpoints": true
},
{
"idx": 54,
"version": "7",
"when": 1747355689811,
"tag": "0054_careless_ultron",
"breakpoints": true
},
{
"idx": 55,
"version": "7",
"when": 1747355837326,
"tag": "0055_sudden_frank_castle",
"breakpoints": true
},
{
"idx": 56,
"version": "7",
"when": 1747355877490,
"tag": "0056_breezy_inertia",
"breakpoints": true
},
{
"idx": 57,
"version": "7",
"when": 1747355892746,
"tag": "0057_orange_lady_deathstrike",
"breakpoints": true
},
{
"idx": 58,
"version": "7",
"when": 1747356938396,
"tag": "0058_cultured_argent",
"breakpoints": true
},
{
"idx": 59,
"version": "7",
"when": 1747357471279,
"tag": "0059_calm_energizer",
"breakpoints": true
},
{
"idx": 60,
"version": "7",
"when": 1747357513268,
"tag": "0060_daffy_overlord",
"breakpoints": true
}
]
}

View File

@@ -1,21 +1,30 @@
import {pgTable, text, timestamp} from "drizzle-orm/pg-core";
import {createSelectSchema} from "drizzle-zod";
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(),
ip: text("ip"),
endpoint: text("endpoint"),
action: text("action"),
lastBody: text("lastBody"),
stats: text("stats"),
lastBody: jsonb("lastBody"),
stats: integer("stats").default(1),
add_date: timestamp().defaultNow(),
upd_date: timestamp().defaultNow(),
}
// (table) => [
// // uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
// uniqueIndex("role_name").on(table.name),
// ]
},
(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