feat(apihits): so i can see if what end points are being used and when and how often
This commit is contained in:
11
database/migrations/0053_short_colleen_wing.sql
Normal file
11
database/migrations/0053_short_colleen_wing.sql
Normal 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");
|
||||
1
database/migrations/0054_careless_ultron.sql
Normal file
1
database/migrations/0054_careless_ultron.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE "apiHits" ADD COLUMN "apiHit_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL;
|
||||
1
database/migrations/0055_sudden_frank_castle.sql
Normal file
1
database/migrations/0055_sudden_frank_castle.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE "apiHits" ALTER COLUMN "stats" SET DATA TYPE integer;
|
||||
1
database/migrations/0056_breezy_inertia.sql
Normal file
1
database/migrations/0056_breezy_inertia.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE "apiHits" DROP COLUMN "stats";
|
||||
1
database/migrations/0057_orange_lady_deathstrike.sql
Normal file
1
database/migrations/0057_orange_lady_deathstrike.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE "apiHits" ADD COLUMN "stats" integer;
|
||||
1
database/migrations/0058_cultured_argent.sql
Normal file
1
database/migrations/0058_cultured_argent.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE "apiHits" ALTER COLUMN "stats" SET DEFAULT 1;
|
||||
1
database/migrations/0059_calm_energizer.sql
Normal file
1
database/migrations/0059_calm_energizer.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE "apiHits" DROP COLUMN "lastBody";
|
||||
1
database/migrations/0060_daffy_overlord.sql
Normal file
1
database/migrations/0060_daffy_overlord.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE "apiHits" ADD COLUMN "lastBody" jsonb;
|
||||
1844
database/migrations/meta/0053_snapshot.json
Normal file
1844
database/migrations/meta/0053_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1851
database/migrations/meta/0054_snapshot.json
Normal file
1851
database/migrations/meta/0054_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1851
database/migrations/meta/0055_snapshot.json
Normal file
1851
database/migrations/meta/0055_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1845
database/migrations/meta/0056_snapshot.json
Normal file
1845
database/migrations/meta/0056_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1851
database/migrations/meta/0057_snapshot.json
Normal file
1851
database/migrations/meta/0057_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1852
database/migrations/meta/0058_snapshot.json
Normal file
1852
database/migrations/meta/0058_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1846
database/migrations/meta/0059_snapshot.json
Normal file
1846
database/migrations/meta/0059_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
1852
database/migrations/meta/0060_snapshot.json
Normal file
1852
database/migrations/meta/0060_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user