refactor: add proper types for all database insert operations

- Add missing Select and Insert types for Auth.js tables (Account, Session, VerificationToken)
- Update all insert operations to use typed New* variables:
  - NewUser for user signup
  - NewItem for adding wishlist items
  - NewSavedWishlist for saving wishlists
- Improves type safety and catches insert errors at compile time
This commit is contained in:
Rasmus Q
2026-03-15 21:38:54 +00:00
parent 6ae82d758e
commit bc680fb60b
5 changed files with 22 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
import { fail, redirect } from '@sveltejs/kit';
import type { Actions, PageServerLoad } from './$types';
import { db } from '$lib/server/db';
import { users } from '$lib/db/schema';
import { users, type NewUser } from '$lib/db/schema';
import { eq } from 'drizzle-orm';
import bcrypt from 'bcrypt';
import { env } from '$env/dynamic/private';
@@ -64,11 +64,12 @@ export const actions: Actions = {
const hashedPassword = await bcrypt.hash(password, 14);
await db.insert(users).values({
const newUser: NewUser = {
name: sanitizedName,
username: sanitizedUsername,
password: hashedPassword
});
};
await db.insert(users).values(newUser);
throw redirect(303, '/signin?registered=true');
}