Add registration helper.

This commit is contained in:
Paul Makles
2021-01-05 18:18:07 +00:00
parent 584f84f9c9
commit e899c5bfc7
4 changed files with 16 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "revolt.js",
"version": "3.0.0-beta.3",
"version": "3.0.0-beta.4",
"main": "dist/index.js",
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
"author": "Paul Makles <insrt.uk>",
+4
View File
@@ -120,6 +120,10 @@ export class Client extends EventEmitter {
/**
* Utility functions.
*/
async register(apiURL: string, data: Auth.CreateRequest): Promise<Auth.CreateResponse> {
return (await Axios.post('/auth/create', data, { baseURL: apiURL })).data;
}
async addFriend(username: string) {
await this.Axios.put(`/users/${username}/friend`);
}
+10
View File
@@ -6,6 +6,16 @@ export namespace Auth {
device_name: string
}
// POST /auth/create
export interface CreateRequest {
email: string,
password: string
}
export interface CreateResponse {
user_id: string
}
export interface Session {
id?: string,
user_id: string,
+1 -1
View File
@@ -11,7 +11,7 @@ export const API_VERSION = {
};
export const LIBRARY_VERSION = {
str: '3.0.0-beta.3',
str: '3.0.0-beta.4',
major: 3,
minor: 0,
patch: 0