Fix bcryptjs imports to use dynamic imports
This commit is contained in:
parent
20c2439ff4
commit
373f103810
2 changed files with 8 additions and 3 deletions
|
|
@ -1,14 +1,15 @@
|
|||
import jwt from 'jsonwebtoken';
|
||||
import bcrypt from 'bcryptjs';
|
||||
import { sql } from '@vercel/postgres';
|
||||
|
||||
const JWT_SECRET = process.env.JWT_SECRET || 'your-secret-key';
|
||||
|
||||
export async function hashPassword(password) {
|
||||
const bcrypt = await import('bcryptjs');
|
||||
return await bcrypt.hash(password, 12);
|
||||
}
|
||||
|
||||
export async function verifyPassword(password, hashedPassword) {
|
||||
const bcrypt = await import('bcryptjs');
|
||||
return await bcrypt.compare(password, hashedPassword);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ export default async function handler(req, res) {
|
|||
`;
|
||||
|
||||
// Create a default admin user
|
||||
const bcrypt = require('bcryptjs');
|
||||
const bcrypt = await import('bcryptjs');
|
||||
const hashedPassword = await bcrypt.hash('admin123', 12);
|
||||
|
||||
await sql`
|
||||
|
|
@ -137,7 +137,11 @@ export default async function handler(req, res) {
|
|||
res.status(200).json({
|
||||
success: true,
|
||||
message: 'Database setup completed successfully!',
|
||||
tables: ['users', 'cards', 'user_cards', 'collections', 'collection_cards', 'decks', 'deck_cards']
|
||||
tables: ['users', 'cards', 'user_cards', 'collections', 'collection_cards', 'decks', 'deck_cards'],
|
||||
adminUser: {
|
||||
email: 'admin@tcgvault.com',
|
||||
password: 'admin123'
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue