const db = require("../../models");
const bcrypt = require("bcrypt");

async function create(user) {
  if (!user.username || !user.password) {
    throw new Error("Username and password are required");
  }

  return await db.user.create({
    ...user,
    password: bcrypt.hashSync(user.password, 10),
  });
}

module.exports = {
  create,
};
