0
Create User
One script reply has been approved by the moderators Verified
Created by adam186 367 days ago Viewed 4051 times
0
Submitted by adam186 Deno
Verified 367 days ago
1
import { Client, ID, Users } from "https://deno.land/x/appwrite@7.0.0/mod.ts";
2

3
/**
4
 * @param id ID of the user to be created. Leave blank to generate a unique ID.
5
 */
6
type Appwrite = {
7
  endpoint: string;
8
  project: string;
9
  key: string;
10
  self_signed: boolean;
11
};
12
export async function main(
13
  auth: Appwrite,
14
  id?: string,
15
  email?: string,
16
  phone?: string,
17
  password?: string,
18
  name?: string,
19
) {
20
  const client = new Client()
21
    .setEndpoint(auth.endpoint)
22
    .setProject(auth.project)
23
    .setKey(auth.key);
24
  const users = new Users(client);
25

26
  return await users.create(
27
    id || ID.unique(),
28
    email || undefined,
29
    phone || undefined,
30
    password || undefined,
31
    name || undefined,
32
  );
33
}
34