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:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user