mirror of
https://github.com/R0m1k3/Menu.git
synced 2026-10-15 03:06:20 +02:00
feat: initialize project with Next.js, Prisma, and admin dashboard functionality
This commit is contained in:
commit
b73aa8616b
37 files changed
+8711
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
import bcrypt from 'bcrypt';
|
||||
|
||||
/**
|
||||
* Hash a password using bcrypt.
|
||||
* @param password - The plain text password.
|
||||
* @returns The hashed password.
|
||||
*/
|
||||
export async function hashPassword(password: string): Promise<string> {
|
||||
const saltRounds = 12;
|
||||
return await bcrypt.hash(password, saltRounds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify a password against a hash.
|
||||
* @param password - The plain text password.
|
||||
* @param hash - The hashed password.
|
||||
* @returns True if the password matches.
|
||||
*/
|
||||
export async function verifyPassword(password: string, hash: string): Promise<boolean> {
|
||||
return await bcrypt.compare(password, hash);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { PrismaBetterSqlite3 } from '@prisma/adapter-better-sqlite3';
|
||||
|
||||
const globalForPrisma = global as unknown as { prisma: PrismaClient };
|
||||
|
||||
const createPrismaClient = () => {
|
||||
const dbUrl = process.env.DATABASE_URL || 'file:./dev.db';
|
||||
const adapter = new PrismaBetterSqlite3({ url: dbUrl });
|
||||
|
||||
return new PrismaClient({ adapter });
|
||||
};
|
||||
|
||||
export const prisma = globalForPrisma.prisma || createPrismaClient();
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
|
||||
Reference in new issue
Block a user