28 lines
509 B
TypeScript
28 lines
509 B
TypeScript
|
import { Router } from "express";
|
||
|
import { hash as bcryptHash } from "bcrypt";
|
||
|
|
||
|
import { prisma } from "./db";
|
||
|
|
||
|
const router = Router();
|
||
|
|
||
|
router.post("/user/register", async (req, res) => {
|
||
|
const body = req.body;
|
||
|
|
||
|
const email = body.email;
|
||
|
const password = body.password;
|
||
|
const passwordHash = await bcryptHash(password, 10);
|
||
|
|
||
|
const newUser = await prisma.user.create({
|
||
|
"data": {
|
||
|
email,
|
||
|
passwordHash,
|
||
|
},
|
||
|
});
|
||
|
|
||
|
res.send({
|
||
|
"id": newUser.id,
|
||
|
});
|
||
|
});
|
||
|
|
||
|
export default router;
|