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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mahfuz-js-frontend

v1.0.6

Published

Frontend Library For Mahfuz-js

Readme

Mahfuz-JS Frontend Library Documentation

Mahfuz-JS is a lightweight and extensible frontend library designed to simplify API interactions and version management in modern JavaScript applications. This library provides a structured interface to interact with REST APIs and manage application update logic using GitHub releases.


Table of Contents

  1. Installation

  2. Frontend Class

  3. UpdateChecker Class

  4. Error Handling


Installation

Install via npm:

npm install mahfuz-js-frontend

Import into your project:

import { Frontend, UpdateChecker } from "mahfuz-js";

Frontend Class

Initialization

const frontend = new Frontend();

ConnectToBackend

Establish a connection to your backend API.

frontend.ConnectToBackend(import.meta.env.VITE_BACKEND_URL);

If no backend URL is provided, a SweetAlert modal will prompt the user with setup instructions.

AddInterceptors

Log all requests and responses for easier debugging.

frontend.AddInterceptors();

HTTP Methods

All HTTP methods return the full response object or the error.

await frontend.get("/api/users");
await frontend.post("/api/create", { name: "John" });
await frontend.put("/api/user/1", { name: "Updated" });
await frontend.patch("/api/user/1", { age: 30 });
await frontend.delete("/api/user/1");

Concurrent Requests

Execute multiple requests simultaneously.

const responses = await frontend.ConcurrentRequests([
  frontend.get("/api/a"),
  frontend.get("/api/b")
]);

Cancelable Requests

Create and cancel long-running requests.

const source = frontend.CancelRequest();
frontend.Server.post("/api/data", {}, { cancelToken: source.token });
source.cancel("Operation canceled by user.");

Alternative using helper:

await frontend.SendWithCancel("/api/data", { id: 123 });

File Upload

Upload files with progress tracking.

const response = await frontend.UploadFileToBackend("/api/upload", file);

UpdateChecker Class

Initialization

const checker = new UpdateChecker({
  GithubUsername: "your-username",
  RepoName: "your-repo",
  RepoToken: "your-github-token"
});

CheckLatestVersion

Fetch the latest release based on OS.

const result = await checker.CheckLatestVersion("windows");
if (result.success) {
  window.open(result.downloadUrl);
}

Supported OS values:

  • windows
  • mac
  • linux

Error Handling

All methods return either a response object or an error. Use try-catch or conditional checks to handle them properly.

try {
  const response = await frontend.get("/api/data");
  if (response.status === 200) {
    // handle success
  }
} catch (error) {
  console.error("API Error:", error);
}

Notes

  • Always ensure your environment variable VITE_BACKEND_URL is set.
  • Protect your GitHub token. Avoid exposing it in the frontend in production.

Mahfuz-JS: Built for simplicity, designed for power.