Edits history of script submission #22336 for ' Create User (appwrite)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import { Client, ID, Users } from "[email protected]";
    
    /**
     * @param id ID of the user to be created. Leave blank to generate a unique ID.
     */
    type Appwrite = {
      endpoint: string;
      project: string;
      key: string;
      self_signed: boolean;
    };
    export async function main(
      auth: Appwrite,
      id?: string,
      email?: string,
      phone?: string,
      password?: string,
      name?: string,
    ) {
      const client = new Client()
        .setEndpoint(auth.endpoint)
        .setProject(auth.project)
        .setKey(auth.key);
      const users = new Users(client);
    
      return await users.create(
        id || ID.unique(),
        email || undefined,
        phone || undefined,
        password || undefined,
        name || undefined,
      );
    }
    

    Submitted by hugo989 1 day ago