Glorious Crud
A bare minimum and extensible crud generator.

Installation
npm i -S gcrud
Usage
Basic
The purpose of this lib is to remove all the effort involved in creating a default crud as well as keeping everything under your control through its options.
const express = require('express');
const GCrud = require('gcrud');
const app = express();
const gCrud = new GCrud('databaseUrl', 'databaseName', app);
const beersResource = gCrud.build('beers');
beersResource.get('/beers/:id/awards', (req, res) => {
});
app.listen(9000, () => {
console.log(`Running on port 9000...`);
});
Options
Using options, you can override any method by doing as follows:
const options = {
get: (req, res) => {
}
}
const beersResource = gCrud.build('beers', options);
You can also set listeners to be called on success or on error of some method:
const options = {
onGetSuccess: (req, res, response) => {
},
onGetError: (req, res, err) => {
},
onPostSuccess: (req, res, response) => {
},
onPostError: (req, res, err) => {
},
onPutSuccess: (req, res, response) => {
},
onPutError: (req, res, err) => {
},
onDeleteSuccess: (req, res, response) => {
}
onDeleteError: (req, res, err) => {
}
}
const beersResource = gCrud.build('beers', options);
Contributing
git clone git@github.com:rafaelcamargo/glorious-crud.git
- Go to the project directory
cd glorious-crud
- Install the project dependencies
npm install
node src/app.js
curl http://localhost:9000/beers -H 'content-type: application/json' -d '{"name":"Opa Bier"}'
NOTE
Check out below how to configure MongoDB on your machine before making any request to the API.
Database
-
Install MongoDB following its website instructions.
-
Create a database called gcrud.
-
Create a collection called beers.
-
Start mongo on the default port(27017): Type mongod on your terminal.
Tools
Deployment Services
The services I recommend to get your ideas out of your head are:
- 1 GB Transfer, 1 GB Memory, 1 CPU, 512 MB Storage for $0/mo
- 512 MB Storage, 3 node replica set for $0/mo