0.1.4 ā¢ Published 4 years ago
restbest v0.1.4
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)
- Download and install
$ npx restbest
- You will need to install and run MongoDB in another terminal instance.
$ mongod
- 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
- Clone the repository and install dependencies with 'yarn' or 'npm install'
$ git clone https://github.com/tguelcan/restbest
$ yarn
rename the .env.example file to .env
You will need to install and run MongoDB in another terminal instance.
$ mongod
- 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 āļø