fix: refactor user creation to store user in a variable before trade creation
Build Images and Deploy / Update-PROD-Stack (push) Successful in 1m26s
Build Images and Deploy / Update-PROD-Stack (push) Successful in 1m26s
This commit is contained in:
@@ -36,9 +36,20 @@ export async function POST(req: NextRequest) {
|
|||||||
|
|
||||||
const passwordHash = await bcrypt.hash(password, 12)
|
const passwordHash = await bcrypt.hash(password, 12)
|
||||||
|
|
||||||
await prisma.user.create({
|
const user = await prisma.user.create({
|
||||||
data: { username, displayUsername, passwordHash },
|
data: { username, displayUsername, passwordHash },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await prisma.trade.create({
|
||||||
|
data: {
|
||||||
|
userId: user.id,
|
||||||
|
type: 'ACCOUNT_OPEN',
|
||||||
|
shares: 0,
|
||||||
|
price: 0,
|
||||||
|
total: 2000,
|
||||||
|
profit: 2000,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
return NextResponse.json({ ok: true }, { status: 201 })
|
return NextResponse.json({ ok: true }, { status: 201 })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user