next-learn
next-learn copied to clipboard
Docs: `seed.js` should be `app/seed/routes.ts`
Issue
- Under Chapter 6: Setting Up Your Database, the step Seed your database mentioned
Inside of
/app
, there's a folder called seed. Uncomment this file. This folder contains a Next.js Route Handler, calledroute.ts
, that will be used to seed your database.
Here under route.ts
, bcrypt
package is used to hash users' passwords upon creation.
import bcrypt from 'bycrypt';
...
async function seedUsers() {
...
const insertedUsers = await Promise.all(
users.map(async (user) => {
const hashedPassword = await bcrypt.hash(user.password, 10); // bcrypt is used here
return client.sql`
INSERT INTO users (id, name, email, password)
VALUES (${user.id}, ${user.name}, ${user.email}, ${hashedPassword})
ON CONFLICT (id) DO NOTHING;
`;
}),
);
}
- However, under Chapter 15: Adding Authentication, the step Password Hashing metnioned
In your
seed.js
file, you used a package called bcrypt to hash the user's password before storing it in the database.
This is misleading, as there is no longer a seed.js
file (apparently based on previous issues, this file was there in the past).
Proposed solution
Change seed.js
to app/seed/routes.ts
to reflect the current file structure accurately.