0.1.4 ā€¢ Published 4 years ago

restbest v0.1.4

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Build Status Coverage Status dependencies Status devDependencies Status Maintainability Heroku CI Status

restbest is a customizable rest backend and productive generator. It is based on NodeJS, Restify, Mongodb and Mongoose.

  • RESTful - It follows the best practices
  • BABEL7 - with ESLint
  • User registration API - Using restify-jwt-community
  • Listing query strings - q, page, limit, fields etc. already provided by restify-mongoose
  • Standard error responses - restify-errors
  • Unit and integration tests - Using Jest
  • Continuous integration support - Using Travis CI
  • API docs generator - Using apidoc

#ļøāƒ£ Commands you can use

After you clone this repository, these commands are available in package.json. You can use npm or yarn.

$ yarn test # test using Jest
$ yarn run test:coverage # test and open the coverage report in the browser
$ yarn run lint # lint using ESLint
$ yarn run dev # run the API in development mode
$ yarn run docs # generate API docs
$ yarn run build # build into /lib
$ yarn run serve # serve from /lib
$ yarn run generate # generate a new /api endpoint or sercice

šŸš€ Getting started - Playing locally

Easy to use with npx (recommended)

  1. Download and install
$ npx restbest
  1. You will need to install and run MongoDB in another terminal instance.
$ mongod
  1. Go to the /restbest folder and run the server in development mode.
$ yarn run dev
Restify server listening on http://0.0.0.0:9000, in development mode

Manual Setup

  1. Clone the repository and install dependencies with 'yarn' or 'npm install'
$ git clone https://github.com/tguelcan/restbest
$ yarn
  1. rename the .env.example file to .env

  2. You will need to install and run MongoDB in another terminal instance.

$ mongod
  1. Run the server in development mode.
$ yarn run dev
Restify server listening on http://0.0.0.0:9000, in development mode

And voila! We have connected our restful backend application!

šŸ¤– Use the Generator

$ yarn run generate
? What do you want to generate? (Use arrow keys)
āÆ service - Create a new service
  api endpoint - Create a new api endpoint (/api/endpoint)

Service Generator

? name of the service

You can choose the type of the service

? ? which kind of service you want to generate? (Use arrow keys)
āÆ MIDDLEWARE

It generates the following files

āœ”  ++ /src/services/yourMiddleware/index.js

Api Generator

You can choose the endpoint methods

> to toggle all, <i> to invert selection)
āÆā—Æ GET
 ā—Æ POST
 ā—Æ PATCH
 ā—Æ DELETE

It generates the following files

āœ”  ++ /test/api/+article.test.js
āœ”  ++ /src/api/+article/index.js
āœ”  ++ /src/api/+article/model.js
āœ”  ++ /src/api/+article/controller.js

Doc Generator

$ yarn run docs

It generates the following files

āœ”  ++ /docs/index.html
āœ”  ++ API.md

šŸš€ Deployment

Heroku example

$ heroku create
$ heroku config:set APP_NAME=yourappname MASTER_KEY=changeMeMasterKey123 JWT_SECRET=changeMe123
$ heroku addons:create mongolab
$ git push heroku master
$ heroku open

šŸ“ Todo

  • Add Auth
    • Local Auth āœ”ļø
    • Roles āœ”ļø
    • Social Auth
  • Add generator āœ”ļø

License

MIT