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

mahfuz-js-frontend

v1.0.5

Published

Frontend Library For Mahfuz-js

Downloads

256

Readme

Mahfuz JS MERN Stack Library

Overview

Mahfuz JS is a Node.js MERN Stack library that provides various utilities including server setup, database connection, encryption, email sending, and GitHub release checking.

Installation

To install the module, use npm:

npm install mahfuz-js

Usage

Importing the Module

First, import the required classes from the module:

import { Backend, DatabaseConnector, Utils, ApiResponse, ApiError, MahfuzMailer, UpdateChecker } from 'mahfuz-js';

Backend Class

The Backend class sets up an Express server with necessary middleware.

const backend = new Backend();
backend.startServer();

DatabaseConnector Class

The DatabaseConnector class provides methods to connect to MongoDB and MongoDB Atlas.

Example Usage:

MongoDB

const dbConfig = {
  Host: 'localhost',
  Port: 27017,
  Username: 'your-username',
  Password: 'your-password',
  DbName: 'your-db-name'
};

const dbConnector = new DatabaseConnector(dbConfig);
dbConnector.ConnectToMongoDB();

MongoDB Atlas

const dbConfig = {
    SubDomain: 'your-subdomain',
    Username: 'your-username',
    Password: 'your-password',
    Cluster: 'your-cluster-name'
};
const dbConnector = new DatabaseConnector(dbConfig);
dbConnector.ConnectToMongoDBAtlas();

Utils Class

The Utils class provides utility functions for generating random numbers, handling async requests, and encrypting data.

const utils = new Utils();
const randomNumber = utils.GenerateRandomNumber(10);
const encryptedString = utils.Encrypt('your-string');
const isMatch = utils.Compare('your-string', encryptedString);

ApiResponse Class

The ApiResponse class is used to standardize API responses.

const response = new ApiResponse(200, { key: 'value' }, 'Success message');

ApiError Class

The ApiError class is used to standardize API error responses.

const error = new ApiError(400, 'Error message', ['error1', 'error2']);

MahfuzMailer Class

The MahfuzMailer class is used to send emails using nodemailer.

const mailConfig = {
  Name: 'Your Name', \\ Your name or company name
  From: '[email protected]', \\ Your email address that you used to register for the SMTP server
  Host: 'smtp.example.com', \\ Your SMTP server host address 
  Port: 465, \\ Your SMTP server port
  Username: 'your-username', \\ Your SMTP server username that SMTP server provided
  Password: 'your-password' \\ Your SMTP server password that SMTP server provided
};

const mailer = new MahfuzMailer(mailConfig);
mailer.SendMail('[email protected]', 'Subject', '<h1>Email Body</h1>');

UpdateChecker Class

The UpdateChecker class is used to check for the latest release of a GitHub repository and retrieve the download URL for a specific operating system.

const updateConfig = {
  GithubUsername: 'your-github-username',
  RepoName: 'your-repo-name',
  RepoToken: 'your-github-token' \\ Your GitHub personal access token note: please store your tokens securely inside the dot env file
};

const checker = new UpdateChecker(updateConfig);
checker.CheckLatestVersion('windows')
  .then(result => {
    if (result.success) {
      console.log('Download URL:', result.downloadUrl);
    } else {
      console.log('Error:', result.message);
    }
  })
  .catch(error => {
    console.error('Error:', error);
  });

Supported Operating Systems

The CheckLatestVersion method supports the following operating systems:

  • windows (returns .exe files)
  • mac (returns .dmg files)
  • linux (returns .deb files)

Error Handling

The CheckLatestVersion method returns an object with a success property indicating whether the operation was successful. If success is false, the message property contains an error message.

License

This project is licensed under the MIT License.

Author

Mahfuz JS is developed by Mohammad Mahfuz Rahman.

Happy Coding!