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

custom-db-cli

v2.3.6

Published

A CLI tool to for beginner developers who want to add basic form functionality to their web projects without needing to learn backend development. With this package, students can create, read, update, and delete data from forms seamlessly and store it, wi

Downloads

745

Readme

🎨 Custom DB A simple database management tool that lets you perform CRUD operations via the CLI and interact with an API to submit commands. This tool allows developers to quickly manage a local JSON-based database and also provides a server to handle form submissions.

✨ Features

📄 Custom CLI for creating, reading, updating, and deleting records. 🌐 Express API server to run commands via HTTP requests. 📂 JSON-based local storage. 🛠️ Easy integration into any project. 🏗️ Migrate data to MongoDB via CLI.

🚀 Installation To install the custom-db package run the following command:

*npm install custom-db-cli

Installation To install the custom-db package globally run the following command:

*npm install -g custom-db-cli

This will make the custom-db CLI and server commands available globally.

🔧 CLI Usage The custom-db command provides several operations to interact with your local JSON database.

➕ Create a Record custom-db create --name="John Doe" --age=25 --email="[email protected]" --password="password123"

📖 Read All Records custom-db read

This command will display all the records stored in your JSON database.

✏️ Update a Record

custom-db update --id="12345" --name="Jane Doe" --age=26

Replace the id with the actual record ID you want to update.

❌ Delete a Record

custom-db delete --id="12345"

Replace the id with the actual record ID you want to delete.

🏗️ Migrate Data to MongoDB

You can now migrate your JSON data to MongoDB with the following command:

npx custom-db migrateMongo --DbUri="your-connection-string"

🌍 Server Usage custom-db also comes with a built-in server to handle form submissions via HTTP requests.

▶️ Start the Server To start the server, use the following command:

*npx custom-db-server

This will run a server on custom-db-cli.vercel.app. The server provides an API endpoint that you can use to run commands from a form submission or a frontend application.

Example: 🛠️ Running Commands via API Once the server is running, you can send POST requests to https://custom-db-cli.vercel.app/api/run-command to run commands via the API.

Here’s an example of how to submit a command using a POST request:

POST /run-command Content-Type: application/json

{ "command": "custom-db create --name="Alice" --age=24 --email="[email protected]" --password="secret"" } The server will execute the command and return a response.

-🎨 Example: Frontend Form Integration If you want to integrate this with a frontend form (e.g., React), you can use the fetch API to send the command:

const handleSubmit = (e) => {
  e.preventDefault();

  const command = `custom-db create --name="${formData.name}" --age="${formData.age}" --email="${formData.email}" --password="${formData.password}"`;

  fetch('https://custom-db-cli.vercel.app/api/run-command', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ command }),
  })
    .then((response) => response.json())
    .then((data) => {
      console.log('Form Data Submitted:', data);
      alert('Record created successfully!');
    })
    .catch((error) => {
      console.error('Error:', error);
    });
};
This approach allows users to submit forms, and behind the scenes, your package will execute the CLI commands.