All Projects → glorious-codes → Glorious Crud

glorious-codes / Glorious Crud

A bare minimum and extensible crud generator

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Glorious Crud

Curriculum
Dive into our 7-month web development program covering HTML, CSS, Javascript, Node, and React!
Stars: ✭ 453 (+906.67%)
Mutual labels:  mongodb, expressjs
Mean Angular5 Passport Authentication
Securing MEAN Stack (Angular 5) Web Application using Passport Authentication
Stars: ✭ 24 (-46.67%)
Mutual labels:  mongodb, expressjs
Madclones
A collection of frameworks that I love with a strong focus on clean code, testing, software architecture/design and devops.
Stars: ✭ 480 (+966.67%)
Mutual labels:  mongodb, expressjs
Vue Nodejs Youtube Clone
This is the frontend (VueJS) of the Youtube clone called VueTube.
Stars: ✭ 314 (+597.78%)
Mutual labels:  mongodb, expressjs
Mean Angular4 Chat App
MEAN stack with Angular 4 Chat App
Stars: ✭ 41 (-8.89%)
Mutual labels:  mongodb, expressjs
Practicalnode
Practical Node.js, 1st and 2nd Editions [Apress] 📓
Stars: ✭ 3,694 (+8108.89%)
Mutual labels:  mongodb, expressjs
Project mern memories
This is a code repository for the corresponding video tutorial. Using React, Node.js, Express & MongoDB you'll learn how to build a Full Stack MERN Application - from start to finish. The App is called "Memories" and it is a simple social media app that allows users to post interesting events that happened in their lives.
Stars: ✭ 747 (+1560%)
Mutual labels:  mongodb, expressjs
Builderbook
Open source web application to learn JS stack: React, Material-UI, Next.js, Node.js, Express.js, Mongoose, MongoDB database.
Stars: ✭ 3,015 (+6600%)
Mutual labels:  mongodb, expressjs
Oauth2orize resource owner password example
This is an example of the oAuth resource owner password flow using oauth2orize, express 4 and mongoDB.
Stars: ✭ 31 (-31.11%)
Mutual labels:  mongodb, expressjs
Checksheet Manager
Checksheet Manager for college checksheets. Created with AngularJS and Node/Express/MongoDB.
Stars: ✭ 31 (-31.11%)
Mutual labels:  mongodb, expressjs
Mern Social
A MERN stack based social media application [Full-Stack React Projects]
Stars: ✭ 288 (+540%)
Mutual labels:  mongodb, expressjs
Node Production
Take Your Node.js Project to The Production Environment (VPS/Dedicated Server).
Stars: ✭ 35 (-22.22%)
Mutual labels:  mongodb, expressjs
Mevn Boilerplate
A fullstack boilerplate with Mongo, ExpressJS, VueJS and NodeJS.
Stars: ✭ 277 (+515.56%)
Mutual labels:  mongodb, expressjs
Youtube Clone Nodejs Api
VueTube is a YouTube clone built with nodejs, expressjs & mongodb. This is the RESTful API repository.
Stars: ✭ 441 (+880%)
Mutual labels:  mongodb, expressjs
Nest Mean
NestJS Tutorial Repository
Stars: ✭ 250 (+455.56%)
Mutual labels:  mongodb, expressjs
Rest Api Nodejs Mongodb
A boilerplate for REST API Development with Node.js, Express, and MongoDB
Stars: ✭ 672 (+1393.33%)
Mutual labels:  mongodb, expressjs
Angular2 Express Mongoose Gulp Node Typescript
AngularJS 2 (Updated to 4.2.0) Mean Stack application which uses Angular2, Gulp, Express, Node, MongoDB (Mongoose) with Repository Pattern Business Layer
Stars: ✭ 201 (+346.67%)
Mutual labels:  mongodb, expressjs
Bookmarks.dev
Bookmarks and Code Snippets Manager for Developers & Co
Stars: ✭ 218 (+384.44%)
Mutual labels:  mongodb, expressjs
Awesome Javascript Interviews
Popular JavaScript / React / Node / Mongo stack Interview questions and their answers. Many of them, I faced in actual interviews and ultimately got my first full-stack Dev job :)
Stars: ✭ 939 (+1986.67%)
Mutual labels:  mongodb, expressjs
Foodeazy
Stars: ✭ 34 (-24.44%)
Mutual labels:  mongodb, expressjs

Glorious Crud

A bare minimum and extensible crud generator.

CircleCI codecov

Installation

npm install @glorious/crud --save

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('@glorious/crud');

const app = express();
const gCrud = new GCrud('databaseUrl', 'databaseName', app);

// The line below will make the following endpoints available:
// GET    /beers
// GET    /beers/:id
// POST   /beers
// PUT    /beers/:id
// DELETE /beers/:id
const beersResource = gCrud.build('beers');

// From here, you can add any other custom endpoint you need.
beersResource.get('/beers/:id/awards', (req, res) => {
  // Your specific needs go here.
});

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) => {
    // This implementation will override get method.
    // The same can be done for any other method:
    // post, put, delete.
  }
}

const beersResource = gCrud.build('beers', options);

You can also set listeners to be called on success or on error of some method:

const options = {
  // Executes after every successful get request
  onGetSuccess: (req, res, response) => {
    // response is an object containing "status" (200) and "body".
  },
  // Executes after every failed get request
  onGetError: (req, res, err) => {
    // err is an object containing "status" (4xx or 5xx) and "body".
  },
  // Executes after every successful post request
  onPostSuccess: (req, res, response) => {
    // response is an object containing "status" (201) and "body".
  },
  // Executes after every failed post request
  onPostError: (req, res, err) => {
    // err is an object containing "status" (4xx or 5xx) and "body".
  },
  // Executes after every successful put request
  onPutSuccess: (req, res, response) => {
    // response is an object containing "status" (204).
  },
  // Executes after every failed put request
  onPutError: (req, res, err) => {
    // err is an object containing "status" (4xx or 5xx) and "body".
  },
  // Executes after every successful delete request
  onDeleteSuccess: (req, res, response) => {
    // response is an object containing "status" (204).
  }
  // Executes after every failed delete request
  onDeleteError: (req, res, err) => {
    // err is an object containing "status" (4xx or 5xx) and "body".
  }
}

const beersResource = gCrud.build('beers', options);

Built-in Query Params

When querying resources, you can use some built-in query params:

$sortBy

Sort some collection by one of its attributes:

curl http://localhost:9000/beers?$sortBy=name

$order

Order a sorted request by asc or desc:

curl http://localhost:9000/beers?$sortBy=name&$order=desc

$limit

Limit the number of results:

curl http://localhost:9000/beers?$limit=1

Also, you can use any resource attribute name as a filter:

curl http://localhost:9000/beers?name=Opa%20Bier

Contributing

  1. Install Node. Download the "Recommend for Most Users" version.

  2. Clone the repo:

git clone [email protected]:glorious-codes/glorious-crud.git
  1. Go to the project directory
cd glorious-crud
  1. Install the project dependencies
npm install
  1. run:
node src/app.js
  1. The API will be running on http://localhost:9000.

  2. Make some request to see the API in action:

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

  1. Install MongoDB following its website instructions.

  2. Create a database called gcrud.

  3. Create a collection called beers.

  4. Start mongo on the default port(27017): Type mongod on your terminal.

Tools

  1. Postman is an awesome tool that makes API development a breeze.

  2. MongoDB Compass is the prettiest MongoDB UI client I have ever seen.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].