const mongoose = require("mongoose");
const bcrypt = require("bcryptjs");
require("dotenv").config();

const Admin = require("../models/Admin");

mongoose.connect(process.env.MONGO_URI);

const createAdmin = async () => {
  try {
    const hashPassword = await bcrypt.hash(
      "123456",
      10
    );

    await Admin.create({
      name: "Admin",
      email: "admin@gmail.com",
      password: hashPassword,
    });

    console.log(
      "Admin Created Successfully"
    );

    process.exit();
  } catch (error) {
    console.log(error);
    process.exit();
  }
};

createAdmin();