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

crudeasy

v0.2.21

Published

Easily creates CRUD operations through browseable HTML routes and RESTful API json routes, in Node.js with ExpressJS and MongoDB

Downloads

8

Readme

crudEasy

Dependency Status NPM version

Easily creates CRUD operations through browseable HTML routes and RESTful API json routes, in Node.js with ExpressJS and MongoDB.

  • Requires Node.js, MongoDB and ExpressJS

Installation instructions

  1. Download repository or import with npm install crudeasy (note: npm modules are lowercase);
  2. Rename config-template.js to config.js and change accordingly, to setup your MongoDB user, password, and URL;
  3. Go to the directory crudEasy and run npm install (if not done already);
  4. Require crudEasy with the options set forth below;
  5. Do so for as many routes and collections as needed!

v. 0.1.0

  • First version. just basic CRUD oeprations and full views and RESTful API functions

Documentation

Observations

  • Throughout the code, ":modelModule" is used in comments as an alias to the name given when the module was instantiated, but there is no such param in the routes.
  • Options are passed through as a parameters object, and all of its contents are required, otherwise there will be missing routes and variables. However, error handling of undefined hasn't been implemented yet.

Basic initialization

First instantiate a new model by calling var modelInstance = new crudEasy.newModel(url, collectionName); and then use the api and crud routes by calling app.use([route], crudEasy.crudRoute(modelInstance, optionsObject)); and app.use([/api/route],crudEasy.apiRoute(modelInstance, optionsObject));.

Options

options = {
    url:            "mongodb://<username>:<password>@127.0.0.1:27017/mymongodb", // any valid full mongodb url.
    collection:     "nameOfCollectionInMongoDB", //any MongoDB valid name
    defaultPerPage: 10,   // number of items to be shown in each list view. *Must* be multiplier of 10, as per MongoDB's specification
    routeNew:       "/new",   // or 'n' or localized name, or any URL valid component
    routeDelete:    "/:item/delete", // the param here *must* be :item. Just change the word 'delete'.
    routeEdit:      "/:item/edit",   // the param here *must* be :item Just change the word 'edit'
    labelNew:       "New",           // this is just to be passed as a variable to the rendering engine
    labelEdit:      "Edit",          // this is just to be passed as a variable to the rendering engine
    viewNew:        "edit.jade",     //or any other view to be rendered with app.render(). Remember to set de rendering engine in the app().
    viewItem:       "view.jade",     //or any other view to be rendered with app.render(). Remember to set de rendering engine in the app().
    viewList:       "list.jade",     //or any other view to be rendered with app.render(). Remember to set de rendering engine in the app().
    viewEdit:       "edit.jade"     //or any other view to be rendered with app.render(). Remember to set de rendering engine in the app().
}

Basic code sample (example)

// Calls the Module 3 times, for routes and collections Movies and Actors.
var crudEasy = require ('crudEasy');

//  Movies CRUD module
var optionsMovies = {
    url:            "mongodb://<username>:<password>@127.0.0.1:27017/cinemadb",
    collection:     "movies",
    defaultPerPage: 10,
    routeNew:       "/new",
    routeDelete:    "/:item/delete",
    routeEdit:      "/:item/edit",
    labelNew:       "New",
    labelEdit:      "Edit",
    viewNew:        "views/movies/edit.jade", 
    viewItem:       "views/movies/view.jade",
    viewList:       "views/movies/list.jade",
    viewEdit:       "views/movies/edit.jade"
}

var modelMovies = new crudEasy.newModel(optionsMovies.url, optionsMovies.collection);
app.use('/movies', crudEasy.crudRoute(modelMovies, optionsMovies));
app.use('/api/movies',crudEasy.apiRoute(modelMovies, optionsMovies));


//  Actors CRUD module
var optionsActors = {
    url:            "mongodb://<username>:<password>@127.0.0.1:27017/cinemadb",
    collection:     "actors",
    defaultPerPage: 10,
    routeNew:       "/new",
    routeDelete:    "/:item/delete",
    routeEdit:      "/:item/edit",
    labelNew:       "New",
    labelEdit:      "Edit",
    viewNew:        "views/actors/edit.jade", 
    viewItem:       "views/actors/view.jade",
    viewList:       "views/actors/list.jade",
    viewEdit:       "views/actors/edit.jade"
}

var modelActors = new crudEasy.newModel(optionsActors.url, optionsActors.collection);
app.use('/actors', crudEasy.crudRoute(modelActors, optionsActors));
app.use('/api/actors',crudEasy.apiRoute(modelActors, optionsActors));

Contact

Feel free to contact me through my GitHub profile.

From São Paulo, Brazil.

Happy coding!