Skip to content

Instantly share code, notes, and snippets.

@WoolDoughnut310
Created October 28, 2022 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WoolDoughnut310/0b816d95995ece08e600bf795900e520 to your computer and use it in GitHub Desktop.
Save WoolDoughnut310/0b816d95995ece08e600bf795900e520 to your computer and use it in GitHub Desktop.
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