Skip to content

Commit

Permalink
extracting code into function
Browse files Browse the repository at this point in the history
  • Loading branch information
Fractal-Tess committed May 31, 2024
1 parent 0308b95 commit 4df0e60
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app/user/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { InferInsertModel } from 'drizzle-orm';

export const dynamic = 'force-dynamic';

export default async function page() {
async function createUser() {
const pass = faker.internet.password();
const passwordHash = await argon2.hash(pass);
const user = {
Expand All @@ -14,6 +14,11 @@ export default async function page() {
passwordHash,
} satisfies InferInsertModel<typeof schema.user>;
const result = await db.insert(schema.user).values(user);
return { result, user };
}

export default async function Page() {
const { user, result } = await createUser();

return (
<>
Expand Down

0 comments on commit 4df0e60

Please sign in to comment.