Skip to content

Commit

Permalink
chore: refactor page
Browse files Browse the repository at this point in the history
  • Loading branch information
Fractal-Tess committed May 31, 2024
1 parent 900a908 commit 832b9b3
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/app/user/page.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
'use server';
import { db, schema } from '@/db';
import { faker } from '@faker-js/faker';
import * as argon2 from 'argon2';
import { InferInsertModel } from 'drizzle-orm';

export const dynamic = 'force-dynamic';

export default async function page() {
const pass = faker.internet.password();
const passwordHash = await argon2.hash(pass);
const result = await db
.insert(schema.user)
.values([
{
id: Math.random() * 1000,
username: faker.internet.userName(),
eamil: faker.internet.email(),
passwordHash,
},
]);
console.log(result[0].insertId);
return <h1>Hello from user page</h1>;
const user = {
email: faker.internet.email(),
username: faker.internet.userName(),
passwordHash,
} satisfies InferInsertModel<typeof schema.user>;
const result = await db.insert(schema.user).values(user);

return (
<>
<h1>
A user with the name of {user.username} was inserted with an id of{' '}
{result[0].insertId}
</h1>
</>
);
}

0 comments on commit 832b9b3

Please sign in to comment.