Skip to content

Commit

Permalink
update seed script to create a token for default user, and add migration
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsender committed Feb 16, 2024
1 parent 95702c2 commit f60a770
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { randomBytes } from "node:crypto";

import { PrismaClient } from "@prisma/client";
import bcrypt from "bcryptjs";
import { sha256 } from "js-sha256";

const prisma = new PrismaClient();

async function seed() {
const hashedPassword = await bcrypt.hash("letmeinplease", 10);
const newToken = randomBytes(16).toString("hex");
const hashedNewToken = sha256(newToken);

const user = await prisma.user.create({
data: {
email: "[email protected]",
token: hashedNewToken,
password: {
create: {
hash: hashedPassword,
Expand Down

0 comments on commit f60a770

Please sign in to comment.