ExpressKit JS is a client SDK for interacting with my express-kit backend starter kit
To install ExpressKit JS, you can use npm or yarn:
npm install express-kit-js
or
yarn add express-kit-js
First, import the ExpressKit
class and create an instance with your backend's base URL:
import ExpressKit from 'express-kit-js';
const kit = new ExpressKit('https://your-backend-url.com');
Orrr, you can even create an expendable class to add new functions to it:
import ExpressKit from 'express-kit-js;
class ExpendableKit extends ExpressKit {
async requestSomthingFromFiles() {
try {
return await this.request("GET", "/files?id=asdfarwe32");
} catch (err){
throw err;
}
}
}
const kit = new ExpendableKit("https://your-backend-url.com");
Signs in a user with the given credentials.
await kit.signInUser({ email: 'user@example.com', password: 'password' });
Signs out the current user.
await kit.signOut();
Requests email verification for the given email.
const message = await kit.requestEmailVerfication('user@example.com');
Requests a password reset for the given email.
const message = await kit.requestPasswordReset('user@example.com');
Resets the password with the given credentials.
const message = await kit.resetPassword({ currentPassword: 'oldPassword', newPassword: 'newPassword' });
Gets a list of uploaded files.
const files = await kit.getUploadedFiles();
Gets an uploaded file by its ID.
const file = await kit.getUploadedFile('fileId');
Uploads a file.
const message = await kit.uploadFile(file);
Updates an existing file with a new file.
const message = await kit.updateFileUsingFile('fileId', file);
Deletes a file by its ID.
const message = await kit.deleteFile('fileId');
Gets a list of all users.
const users = await kit.getAllUsers();
Gets the current user.
const user = await kit.getCurrentUser();
Updates the current user with the given data.
const updatedUser = await kit.updateCurrentUser({ displayName: 'New Name' });
Creates a new user with the given data.
const newUser = await kit.createNewUser({ email: 'newuser@example.com', passwordHash: 'hashedPassword' });
Gets a user by their ID.
const user = await kit.getUser('userId');
Updates a user with the given ID and data.
const updatedUser = await kit.updateUser('userId', { displayName: 'Updated Name' });
Deletes a user by their ID.
const message = await kit.deleteUser('userId');
Makes a general request with the given method, URL, and options.
const response = await kit.request('GET', '/custom-endpoint');
export interface User {
email: string;
displayName?: string;
passwordHash?: string;
isVerified?: boolean;
id?: string;
}
export interface UserCredentionals {
email: string;
password: string;
}
export interface PasswordResetCreds {
currentPassword: string;
newPassword: string;
}
export interface KitFile {
filename: string;
ContentType: string;
size: number;
id: string;
}
This documentation covers the basic usage and functionality of the ExpressKit JS SDK. For more detailed information, refer to the backend source coude