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

protocrud

v0.0.6

Published

A CLI that starts a server that makes any CRUD REST request work instantly.

Downloads

4

Readme

protocrud

A CLI that starts a server that makes any CRUD REST request work instantly.

Requirements

  • nodejs
  • mongodb

Installing

For global use run

npm install --global protocrud

For use in a project:

yarn add -D protocrud or npm install -D protocrud

Usage

Run protocrud in your shell, a server has now started where every restful endpoint will be available.

Example for a todo model:

| Request Method | Url | Description | Response | | -------------- | ----------- | --------------------------- | ---------------------- | | GET | /todo | Fetches all todos | An array of todos | | GET | /todo/:id | Fetches a single todo by id | A single todo | | POST | /todo | Creates a todo | The newly created todo | | PUT | /todo/:id | Updates a todo | The updated todo | | DELETE | /todo/:id | Deletes a todo | Void |

The todo model (as seen in the url) is arbitrary, you can use any model name you like.

Configuration

To configure protocrud you can add a protocrud.config.json file next to your package.json, a custom path to the config file can be provided using the --config=path/to/config.json flag. You can override the config file by providing options to the cli, such as the --clean flag

protocrud.config.json
{
    "port": "1234",
    "clean": false,
    "db": {
        "name": "database-name"
    }
}

Initial Data

When using protocrud for a project, it can be useful to provide some initial data for your colleagues. This can be provided by creating a protocrud.data.json file like so:

protocrud.data.json
{
    "todo": [
        {
            "title": "Try protocrud",
            "completed": false
        },
        {
            "_id": "5b7deb5c18e71715587dfde7",
            "title": "Read protocrud documentation",
            "completed": true
        }
    ]
}

Options

You can provide several options to the protocrud cli to use a different database or port for example.

All of these can also be used in the protocrud.config.json file, options with dots in their names refer to deep objects, see protocrud.config.json

| Option | Default | Usage | Description | | ----------- | ------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------ | | port | 1342 | protocrud --port=1342 | The port the protocrud server will be listening on. | | clean | false | protocrud --clean | Removes all data when starting, imports data from the configured data file if it exists. | | config | "protocrud.config.json" | protocrud --config=protocrud.config.json | Path to the protocrud.config.json file. | | prefix | "" | protocrud --prefix=/api | Path to listen on for requests, with a prefix of /api requests look like GET /api/todo | | data | "protocrud.data.json" | protocrud --data=protocrud.data.json | Path to the file with "clean" or initial data. | | db.name | "protocrud" | protocrud --db.name=protocrud | The name of the mongo database that should be used to store data. | | db.hostname | "localhost" | protocrud --db.hostname=localhost | The hostname the mongo db server is running on | | db.port | 27017 | protocrud --db.port=27017 | The port the mongo db server is running on | | db.user | undefined | protocrud --db.user=username | The user used to connect to the mongo db server | | db.password | undefined | protocrud --db.password=username | The password used to connect to the mongo db server |