feat(api): Implement Challenges API

This commit is contained in:
Jesse Wierzbinski 2024-06-13 22:03:51 -10:00
parent 924ff9b2d4
commit 8f9472b221
No known key found for this signature in database
26 changed files with 2656 additions and 104 deletions

View file

@ -0,0 +1 @@
ALTER TABLE "CaptchaChallenges" RENAME TO "Challenges";

File diff suppressed because it is too large Load diff

View file

@ -190,6 +190,13 @@
"when": 1718234302625,
"tag": "0026_neat_stranger",
"breakpoints": true
},
{
"idx": 27,
"version": "7",
"when": 1718327596823,
"tag": "0027_peaceful_whistler",
"breakpoints": true
}
]
}

View file

@ -16,16 +16,18 @@ import {
} from "drizzle-orm/pg-core";
import type { Source as apiSource } from "~/types/mastodon/source";
export const CaptchaChallenges = pgTable("CaptchaChallenges", {
export const Challenges = pgTable("Challenges", {
id: uuid("id").default(sql`uuid_generate_v7()`).primaryKey().notNull(),
challenge: jsonb("challenge").notNull().$type<Challenge>(),
expiresAt: timestamp("expires_at", {
precision: 3,
mode: "string",
}).default(
// 5 minutes
sql`NOW() + INTERVAL '5 minutes'`,
),
})
.default(
// 5 minutes
sql`NOW() + INTERVAL '5 minutes'`,
)
.notNull(),
createdAt: timestamp("created_at", { precision: 3, mode: "string" })
.defaultNow()
.notNull(),