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

appjx

v1.1.6

Published

A Node.js module to interact with storage APIs using axios and FormData.

Downloads

580

Readme

appJx

Overview

appJx is a powerful and easy-to-use Node.js library designed to simplify file management tasks, including file uploads, updates, deletions, and storage management. Whether you're building a simple application that needs file storage capabilities or a complex system with vault-based file organization, appJx provides a flexible and efficient solution to manage your files with ease.

The library is built to handle various file operations securely and efficiently, ensuring that your file management needs are met without compromising on performance or security.

Features

  • File Uploading: Seamlessly upload files to designated vaults, with support for various file types and sizes.
  • File Listing: Retrieve a list of files stored within a specific vault, allowing for easy file management and organization.
  • File Updating: Update metadata or content of existing files to keep your storage up-to-date.
  • File Deletion: Safely remove files from storage when they are no longer needed.
  • Vault Management: Access and manage details of storage vaults to keep track of where your files are stored.

These sections provide a clear introduction to what appJx does and highlight its key features, making it easier for users to understand the purpose and capabilities of the package.

Installation

To start using appJx, you can install it via npm or Yarn. Ensure you have Node.js installed on your machine.

npm install appJx
yarn add appJx

Usage

  1. Importing the Package To use appJx in your project, first import the necessary classes.

For CommonJS (Node.js):

const { FileManager, VaultManager } = require("appJx");

For ES Modules (Node.js):

import { FileManager, VaultManager } from "appJx";
  1. Setting Up the Client

Create an instance of the Client by providing the base URL of your API and an access key for authentication:

const client = new Client({
  baseUrl: "http://localhost:4000",
  accessKey: "YtMQ9T0YAUyK-XxRgeI9cpQ2vqjSlN8NHOPSxsdsSmk",
});
  1. Using the Storage Class

Initialize the Storage class with the client:

const storage = new Storage(client);

Upload a File:

const fileData = Buffer.from("Your file data");
const vaultId = "your-vault-id";

storage
  .uploadFile(fileData, vaultId)
  .then((fileId) => {
    console.log(`File uploaded successfully. File ID: ${fileId}`);
  })
  .catch((error) => {
    console.error(`Error uploading file: ${error.message}`);
  });

Retrieving a File List:

storage
  .getFileList(vaultId)
  .then((fileList) => {
    console.log("File List:", fileList);
  })
  .catch((error) => {
    console.error(`Error retrieving file list: ${error.message}`);
  });

Updating a File:

const fileId = "your-file-id";
const newFileData = Buffer.from("Updated file data");
storage
  .updateFile(fileId, newFileData)
  .then(() => {
    console.log("File updated successfully.");
  })
  .catch((error) => {
    console.error(`Error updating file: ${error.message}`);
  });

Deleting a File:

const fileId = "your-file-id";
storage
  .deleteFile(fileId)
  .then(() => {
    console.log("File deleted successfully.");
  })
  .catch((error) => {
    console.error(`Error deleting file: ${error.message}`);
  });

Retrieving Vault Details

storage
  .getVaultDetails(vaultId)
  .then((vaultDetails) => {
    console.log("Vault Details:", vaultDetails);
  })
  .catch((error) => {
    console.error(`Error retrieving vault details: ${error.message}`);
  });

Error Handling

appJx provides error messages that are easy to catch and debug. All methods return Promises, so you can handle errors using .catch() or try-catch with async/await.

storage
  .uploadFile(fileData, vaultId)
  .then((fileId) => {
    console.log(`File uploaded successfully. File ID: ${fileId}`);
  })
  .catch((error) => {
    console.error(`Error uploading file: ${error.message}`);
  });

API Reference

Client

1 Client(config): Initializes a new client.

  • config.baseUrl: The base URL for the API.
  • config.accessKey: The access key for authentication.

Storage

  1. uploadFile(fileData, vaultId): Uploads a file to a specified vault.
  • fileData: The file data as a Buffer.
  • vaultId: The ID of the vault where the file will be stored.
  1. getFileList(vaultId): Retrieves a list of files from a specified vault.
  • vaultId: The ID of the vault.
  1. updateFile(fileId, updates): Updates the metadata of a specified file.
  • fileId: The ID of the file to be updated.
  • updates: An object containing the fields to update.
  1. deleteFile(fileId): Deletes a specified file.
  • fileId: The ID of the file to be deleted.
  1. getVaultDetails(vaultId): Retrieves details about a specified vault.
  • vaultId: The ID of the vault.

license

This project is licensed under the MIT License. See the LICENSE file for more details.

Support

If you have any questions or need help, feel free to reach out by opening an issue or by contacting the project maintainers at [email protected]

Please note that this is just a brief overview of how to use the appJx library. For more details and information about other methods and classes, you can refer to the API Reference section in the documentation.

If you have any questions or need further assistance, feel free to ask.

npm version