quail-rest

1.1.27 • Public • Published

Quail

Hassle free mongodb rest app

Features

  • Uses ACL (Access Control List) to better manage routes. So no route management.
  • Uses built in JWT Token Authentication.
  • Support for prevention of brute force attacks using express-brute
  • Uses sails like models and controllers
  • Blueprints to make life easy
  • Support for embeded documents to enable transactions

Installation

npm install -g quail-cli

Prerequisite

A running instance of mongodb

Getting Started

  1. Create a project by running the command
quail create <myapp>
  1. Change directory to your app and npm install
cd myapp && npm install
  1. Create a model
quail add-model user
 
OR
 
quail m user
  1. Create a controller
quail add-controller user
 
OR
 
quail c user
  1. Run the app
npm start

Quail supports sails like blueprints out of the box but is protected by ACL(access control list). Change your acl to allow the following actions [find , findOne, create, update and destroy] for the user controller

module.exports = {
    routes: {
        authenticated: {},
        not_authenticated: {
         User:{
         find: true,
         findOne: true,
         create: true,
         update: true,
         destroy: true,
         }
        }
    }
}

Now restart the server and send a post request to http://localhost:3000/user with request body

*POST to http://localhost:3000/user
{
    name : 'Quail',
}

Get all the user by sending a get request to http://localhost:3000/user

*GET to http://localhost:3000/user

Get a particular user by sending a get request to http://localhost:3000/user/:id

*GET to http://localhost:3000/user/:id

Update a particular user by sending a put request to http://localhost:3000/user/:id

*PUT to http://localhost:3000/user/:id
{
    name:'Quail is awesome'
}

Destroy a particular user by sending a delete request to http://localhost:3000/user/:id

*DELETE to http://localhost:3000/user/:id
  • Docs coming soon

Readme

Keywords

Package Sidebar

Install

npm i quail-rest

Weekly Downloads

0

Version

1.1.27

License

MIT

Last publish

Collaborators

  • utkarsh85