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

my-crud-api-fatezila

v1.0.0

Published

A simple CRUD API package that can be used as both npm module and npx command

Readme

My CRUD API Package

A simple, flexible CRUD API package that can be used both as an npm module and as an npx command-line tool.

Features

  • Create, Read, Update, Delete operations
  • 🔍 Search functionality with multiple criteria
  • 📊 Statistics and data insights
  • 🖥️ CLI Interface for command-line usage
  • 🌐 HTTP Server mode for API endpoints
  • 📦 NPM Module for programmatic usage

Installation

As an NPM Package (for use in other projects)

npm install my-crud-api

As an NPX Command (global usage)

npx my-crud-api --help

Usage

1. As an NPM Module

const CrudAPI = require('my-crud-api');

// Create a new API instance
const api = new CrudAPI();

// Create a new item
const item = api.create({
  name: 'John Doe',
  email: '[email protected]',
  age: 30
});

// Read all items
const allItems = api.read();

// Read a specific item
const specificItem = api.read(1);

// Update an item
const updatedItem = api.update(1, {
  name: 'Jane Doe',
  age: 31
});

// Delete an item
const result = api.delete(1);

// Search items
const searchResults = api.search({
  name: 'John'
});

// Get statistics
const stats = api.getStats();

2. As an NPX Command

Create an item

npx my-crud-api create "John Doe" --description "Software Developer" --type "person"

Read items

# Read all items
npx my-crud-api read

# Read specific item
npx my-crud-api read 1

Update an item

npx my-crud-api update 1 --name "Jane Doe" --age 31

Delete an item

npx my-crud-api delete 1

Search items

npx my-crud-api search --name "John" --type "person"

Get statistics

npx my-crud-api stats

Start HTTP server

npx my-crud-api server --port 3000

Clear all data

npx my-crud-api clear

3. HTTP Server Mode

When you run the server, it provides REST API endpoints:

npx my-crud-api server

Available endpoints:

  • GET /api/items - Get all items
  • GET /api/items/:id - Get item by ID
  • POST /api/items - Create new item
  • PUT /api/items/:id - Update item
  • DELETE /api/items/:id - Delete item
  • GET /api/search - Search items (with query parameters)
  • GET /api/stats - Get statistics

Example API calls:

# Create an item
curl -X POST http://localhost:3000/api/items \
  -H "Content-Type: application/json" \
  -d '{"name": "John Doe", "email": "[email protected]"}'

# Get all items
curl http://localhost:3000/api/items

# Update an item
curl -X PUT http://localhost:3000/api/items/1 \
  -H "Content-Type: application/json" \
  -d '{"name": "Jane Doe"}'

# Search items
curl "http://localhost:3000/api/search?name=John"

API Reference

CrudAPI Class

Constructor

const api = new CrudAPI();

Methods

create(item)

Creates a new item.

  • Parameters: item (object) - The item to create
  • Returns: The created item with ID and timestamps
  • Throws: Error if item is invalid
read(id?)

Reads one or all items.

  • Parameters: id (number, optional) - Item ID to read
  • Returns: Single item or array of all items
  • Throws: Error if item not found
update(id, updates)

Updates an existing item.

  • Parameters:
    • id (number) - Item ID to update
    • updates (object) - Fields to update
  • Returns: Updated item
  • Throws: Error if item not found
delete(id)

Deletes an item.

  • Parameters: id (number) - Item ID to delete
  • Returns: Success message
  • Throws: Error if item not found
search(criteria)

Searches items by criteria.

  • Parameters: criteria (object) - Search criteria
  • Returns: Array of matching items
getStats()

Gets API statistics.

  • Returns: Statistics object with total items, next ID, etc.
clear()

Clears all data.

  • Returns: Success message

Development

Local Development

  1. Clone the repository
  2. Install dependencies:
    npm install
  3. Test the CLI:
    node bin/cli.js --help
  4. Test the server:
    node index.js

Publishing to NPM

  1. Make sure you're logged in to npm:

    npm login
  2. Update the version in package.json:

    npm version patch  # or minor, major
  3. Publish the package:

    npm publish
  4. Test the published package:

    npx my-crud-api --help

Examples

Example 1: Using in a Node.js Project

// app.js
const CrudAPI = require('my-crud-api');

const api = new CrudAPI();

// Add some sample data
api.create({ name: 'Alice', role: 'Developer' });
api.create({ name: 'Bob', role: 'Designer' });
api.create({ name: 'Charlie', role: 'Manager' });

// Search for developers
const developers = api.search({ role: 'Developer' });
console.log('Developers:', developers);

// Get statistics
const stats = api.getStats();
console.log('Total users:', stats.totalItems);

Example 2: Building a Web Application

// server.js
const express = require('express');
const CrudAPI = require('my-crud-api');

const app = express();
const api = new CrudAPI();

app.use(express.json());

// Your custom routes using the CRUD API
app.get('/users', (req, res) => {
  const users = api.read();
  res.json(users);
});

app.post('/users', (req, res) => {
  const user = api.create(req.body);
  res.status(201).json(user);
});

app.listen(3000, () => {
  console.log('Server running on port 3000');
});

License

MIT

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Support

If you encounter any issues or have questions, please open an issue on the GitHub repository.