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 devRestify 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 devRestify 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? ❯ service - Create a new service api endpoint - Create a new api endpoint
Service Generator
? name of the service
You can choose the type of the service
? ? which kind of service you want to generate? ❯ 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 ✔️