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

@scobru/mogu

v1.2.8

Published

Ipfs database written in ts

Downloads

21

Readme

MOGU

inspired by this post

API Usage

Description: Mogu is a TypeScript-based system that integrates a local database with the InterPlanetary File System (IPFS) and Ethereum blockchain. It enables secure storage, management, and retrieval of encrypted data nodes, leveraging blockchain and IPFS for enhanced data integrity and decentralization.

Features

  • Encrypted local database management.
  • IPFS integration via PinataAPI for decentralized storage.
  • Ethereum blockchain interaction for Content Identifier (CID) management.
  • Flexible and customizable node queries.

Modules

  • db.ts: Logic for local database management.
  • api.ts: API endpoint definitions for database and IPFS interaction.
  • sdk.ts: Software Development Kit for interacting with the Mogu system.
  • pinataAPI.ts: Interface with the Pinata service for IPFS operations.
  • CIDRegistry.sol: Ethereum smart contract for managing CIDs.

Installation

Via NPM

npm install @scobru/mogu

Via GitHub

  1. Clone the repository:

    git clone https://github.com/scobru/mogu.git
  2. Install dependencies:

    npm install
  3. Start the server:

    npm start

Usage

Initializing Mogu

import { Mogu } from "@scobru/mogu";
const mogu = new Mogu("your-key", "pinataApiKey", "pinataApiSecret", "dbName");

Adding a Node

const newNode: EncryptedNode = {
  id: "0",
  type: "FILE",
  name: "my-file",
  parent: "",
  children: [],
  content: "Hello World!",
};

const newNode: EncryptedNode = {
  id: "0",
  type: "DIRECTORY",
  name: "my-directory",
  parent: "",
  children: [],
  content: "",
};

mogu.addNode(newNode);

Querying Nodes

// Query by name
const nodesByName = mogu.queryByName("nodeName");

// Query by type
const nodesByType = mogu.queryByType(NodeType.FILE);

Loading a Database

// Load from local storage
mogu.load("cid");

Saving a Database

// Save to local storage
mogu.store();

Blockchain Integration

import { MoguOnChain } from "@scobru/mogu";
const moguOnChain = new MoguOnChain("contractAddress", signer);

API Reference

  • Add Node: Send a POST request to /api/addNode with the node data in the request body. The node data should be an object that matches the EncryptedNode type.

  • Update Node: Send a POST request to /api/updateNode with the updated node data in the request body.

  • Remove Node: Send a POST request to /api/removeNode with the ID of the node to remove in the request body.

  • Save Database: Send a POST request to /api/save with the encryption key in the request body.

  • Save Database On Chain: Send a POST request to /api/saveOnChain with the encryption key and the contract address in the request body.

  • Load Database From Chain: Send a POST request to /api/loadOnChain with the contract address in the request body.

  • Load Database: Send a POST request to /api/load/:cid with the encryption key in the request body and the CID in the URL.

  • Serialize Database: Send a POST request to /api/serialize with the encryption key in the request body.

  • Query By Name: Send a POST request to /api/queryByName with the name to query in the request body.

  • Query By Type: Send a POST request to /api/queryByType with the type to query in the request body.

  • Query By Content: Send a POST request to /api/queryByContent with the content to query in the request body.

  • Query By Children: Send a POST request to /api/queryByChildren with the children to query in the request body.

  • Query By Parent: Send a POST request to /api/queryByParent with the parent to query in the request body.

  • Get All Nodes: Send a GET request to /api/getAllNodes to retrieve all nodes in the database.

  • Unpin CID: Send a POST request to /api/unPinCID/:cid to unpin a CID from IPFS.

Remember to replace :cid with the actual CID when making requests to /api/load/:cid and /api/unPinCID/:cid.

Contributing

  • Guidelines for contributing to the Mogu project.

License

  • Information about the project's licensing.