import { connect } from "mongoose";
import { SignUpParams, IUser } from "../../Models/Users/Users.Interface";
import UsersManager from "../../Models/Users/Users";

export class SignUpService {
    /**
     * Asynchronously logs in a user.
     *
     * @param {SignUpParams} data - The signup parameters.
     * @return {Promise<IUser>} The session object.
     */
    public async signUp(data: SignUpParams): Promise<IUser> {
        // Destructure email and password from the data object

        await connect(`${process.env.DATABASE_CONNECTION}`);

        const newUser = await UsersManager.signUp(data);

        // Return the user object
        return newUser;
    }
}
