npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

express-kit-js

v1.1.0

Published

ExpressKit JS is a client SDK for interacting with my [express-kit](https://www.npmjs.com/package/@roee1454/express-kit) backend starter kit

Downloads

11

Readme

ExpressKit JS SDK

ExpressKit JS is a client SDK for interacting with my express-kit backend starter kit

Installation

To install ExpressKit JS, you can use npm or yarn:

npm install express-kit-js

or

yarn add express-kit-js

Usage

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");

Authentication Functions

signInUser(userCredentials: UserCredentionals): Promise<string>

Signs in a user with the given credentials.

await kit.signInUser({ email: '[email protected]', password: 'password' });

signOut(): Promise<string>

Signs out the current user.

await kit.signOut();

requestEmailVerfication(email: string): Promise<string>

Requests email verification for the given email.

const message = await kit.requestEmailVerfication('[email protected]');

requestPasswordReset(email: string): Promise<string>

Requests a password reset for the given email.

const message = await kit.requestPasswordReset('[email protected]');

resetPassword(info: PasswordResetCreds): Promise<string>

Resets the password with the given credentials.

const message = await kit.resetPassword({ currentPassword: 'oldPassword', newPassword: 'newPassword' });

File System Functions

getUploadedFiles(): Promise<KitFile[]>

Gets a list of uploaded files.

const files = await kit.getUploadedFiles();

getUploadedFile(id: string): Promise<Buffer>

Gets an uploaded file by its ID.

const file = await kit.getUploadedFile('fileId');

uploadFile(file: File): Promise<string>

Uploads a file.

const message = await kit.uploadFile(file);

updateFileUsingFile(id: string, file: File): Promise<string>

Updates an existing file with a new file.

const message = await kit.updateFileUsingFile('fileId', file);

deleteFile(id: string): Promise<string>

Deletes a file by its ID.

const message = await kit.deleteFile('fileId');

User Functions

getAllUsers(): Promise<User[]>

Gets a list of all users.

const users = await kit.getAllUsers();

getCurrentUser(): Promise<User>

Gets the current user.

const user = await kit.getCurrentUser();

updateCurrentUser(data: any): Promise<User>

Updates the current user with the given data.

const updatedUser = await kit.updateCurrentUser({ displayName: 'New Name' });

createNewUser(user: User): Promise<User>

Creates a new user with the given data.

const newUser = await kit.createNewUser({ email: '[email protected]', passwordHash: 'hashedPassword' });

getUser(id: string): Promise<User>

Gets a user by their ID.

const user = await kit.getUser('userId');

updateUser(id: string, data: any): Promise<User>

Updates a user with the given ID and data.

const updatedUser = await kit.updateUser('userId', { displayName: 'Updated Name' });

deleteUser(id: string): Promise<string>

Deletes a user by their ID.

const message = await kit.deleteUser('userId');

General Request Function

request(method: string, url: string, options?: AxiosRequestConfig): Promise<AxiosResponse>

Makes a general request with the given method, URL, and options.

const response = await kit.request('GET', '/custom-endpoint');

Types

User

export interface User {
  email: string;
  displayName?: string;
  passwordHash?: string;
  isVerified?: boolean;
  id?: string;
}

UserCredentionals

export interface UserCredentionals {
  email: string;
  password: string;
}

PasswordResetCreds

export interface PasswordResetCreds {
  currentPassword: string;
  newPassword: string;
}

KitFile

export interface KitFile {
  filename: string;
  ContentType: string;
  size: number;
  id: string;
}

Conclusion

This documentation covers the basic usage and functionality of the ExpressKit JS SDK. For more detailed information, refer to the backend source coude