Remove dead signup router, unused verification functions, and legacy cleanup query
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 18m37s
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 18m37s
- Delete src/routes/signup.ts (dead code, 410 handler in index.ts remains) - Remove isEmailVerified() and getVerifiedApiKey() from verification.ts (only used by signup) - Remove stale-key cleanup from cleanupStaleData() that queried legacy verifications table - Update usage middleware message: 'Free tier limit' → 'Account limit' - TDD: 8 new tests, removed signup.test.ts (dead), net 556 tests passing
This commit is contained in:
parent
921562750f
commit
7206cb518d
11 changed files with 79 additions and 308 deletions
|
|
@ -172,8 +172,8 @@ export async function initDatabase(): Promise<void> {
|
|||
* - Unverified free-tier API keys (never completed verification)
|
||||
* - Orphaned usage rows (key no longer exists)
|
||||
*/
|
||||
export async function cleanupStaleData(): Promise<{ expiredVerifications: number; staleKeys: number; orphanedUsage: number }> {
|
||||
const results = { expiredVerifications: 0, staleKeys: 0, orphanedUsage: 0 };
|
||||
export async function cleanupStaleData(): Promise<{ expiredVerifications: number; orphanedUsage: number }> {
|
||||
const results = { expiredVerifications: 0, orphanedUsage: 0 };
|
||||
|
||||
// 1. Delete expired pending verifications
|
||||
const pv = await queryWithRetry(
|
||||
|
|
@ -181,18 +181,7 @@ export async function cleanupStaleData(): Promise<{ expiredVerifications: number
|
|||
);
|
||||
results.expiredVerifications = pv.rowCount || 0;
|
||||
|
||||
// 2. Delete unverified free-tier keys (email not in verified verifications)
|
||||
const sk = await queryWithRetry(`
|
||||
DELETE FROM api_keys
|
||||
WHERE tier = 'free'
|
||||
AND email NOT IN (
|
||||
SELECT DISTINCT email FROM verifications WHERE verified_at IS NOT NULL
|
||||
)
|
||||
RETURNING key
|
||||
`);
|
||||
results.staleKeys = sk.rowCount || 0;
|
||||
|
||||
// 3. Delete orphaned usage rows
|
||||
// 2. Delete orphaned usage rows (key no longer exists in api_keys)
|
||||
const ou = await queryWithRetry(`
|
||||
DELETE FROM usage
|
||||
WHERE key NOT IN (SELECT key FROM api_keys)
|
||||
|
|
@ -202,7 +191,7 @@ export async function cleanupStaleData(): Promise<{ expiredVerifications: number
|
|||
|
||||
logger.info(
|
||||
{ ...results },
|
||||
`Database cleanup complete: ${results.expiredVerifications} expired verifications, ${results.staleKeys} stale keys, ${results.orphanedUsage} orphaned usage rows removed`
|
||||
`Database cleanup complete: ${results.expiredVerifications} expired verifications, ${results.orphanedUsage} orphaned usage rows removed`
|
||||
);
|
||||
|
||||
return results;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue