Created
October 28, 2022 14:58
-
-
Save WoolDoughnut310/0b816d95995ece08e600bf795900e520 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from "express"; | |
import getDb from "../db"; | |
import { User } from "../db/types"; | |
import bcrypt from "bcrypt"; | |
const router = express.Router(); | |
router.post("/register", async (req, res) => { | |
const db = getDb(); | |
const users = db.collection<User>("user"); | |
const password = await bcrypt.hash(req.body.password, 10); | |
await users.insertOne({ | |
email: req.body.email, | |
password, | |
username: req.body.username, | |
}); | |
res.status(200).json({ message: "Registered successfully" }); | |
}); | |
export default router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment