21 lines
430 B
TypeScript
21 lines
430 B
TypeScript
import { Player } from "@prisma/client"
|
|
import bcrypt from "bcrypt"
|
|
import prisma from "../../prisma"
|
|
|
|
async function createPlayerDB(
|
|
username: string,
|
|
password: string,
|
|
next: (player: Player) => void
|
|
) {
|
|
const player = await prisma.player.create({
|
|
data: {
|
|
username,
|
|
passwordHash: await bcrypt.hash(password, 10),
|
|
anonymous: false,
|
|
},
|
|
})
|
|
|
|
return next(player)
|
|
}
|
|
|
|
export default createPlayerDB
|