refactor: add proper types for all database insert operations

This commit is contained in:
Rasmus Q
2026-03-15 21:38:54 +00:00
parent e2dbd64277
commit 51df2d5777
5 changed files with 22 additions and 12 deletions
+4 -3
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');
}