A lean boilerplate application for building RESTful APIs (Microservice) in Node.js using hapi.js.Follows industry standard best practices, and uses latest async/await ES8 feature.Bring your own front-end.Plug-in your own Database.
Feature | Summary |
---|---|
Uses latest ES8/ES2017 features (async/await) | Uses latest ES7 and ES8 features including async/await |
Application Configuration via config | Node-config organizes hierarchical configurations for your app deployments. It lets you define a set of default parameters, and extend them for different deployment environments (development, qa, staging, production, etc.). |
Auto Documentation via hapi-swagger | This will self document the API interface. You can also tests your APIs using the Swagger interface. |
Unit and Integration Tests via Mocha with async/await | Demo unit and integration tests using latest ES7/ES8 features. |
Code Coverage via istanbul | Supports code coverage of ES8 code using istanbul and mocha. Code coverage reports are saved in coverage/ directory post yarn test execution. Open coverage/lcov-report/index.html to view coverage report. yarn test also displays code coverage summary on console. Code coverage can also be enforced overall and per file as well, configured via .istanbul.yml |
Logging via bunyan | Bunyan is simple and fast JSON logging library. Logs timestamp, machine name and process ID and most importantly makes it really easy to parse logs as it logs in JSON format. You can selectively turn on/off logs by setting log level via LOG_LEVEL env variable. |
Code Linting via Standard | JavaScript code linting is done using ESLint - a pluggable linter tool for identifying and reporting on patterns in JavaScript. |
API parameter validation via joi | Validate body, params, query, headers and cookies of a request (via middleware) and return a response with errors; if any of the configured validation rules fail. You won't anymore need to make your route handler dirty with such validations. |
Application monitoring via New Relic | Set NEW_RELIC_APP_NAME and NEW_RELIC_LICENSE_KEY environment variables in production environment to get metrics in New Relic Dashboard |
Pre-commit hooks via husky | Runs lint and tests before any commit is made locally, making sure that only tested and quality code goes through |
Uses Sinon for spies, stubs and mocks | Standalone and test framework agnostic JavaScript test spies, stubs and mocks |
Uses nock for mocking http requests in integration tests | Nock is an HTTP mocking and expectations library. It can be used to test modules that perform HTTP requests in isolation. |
Uses yarn over npm | Uses new released yarn package manager by facebook. You can read more about it here |
Docker compatible | Docker and Docker Compose files to develop and deploy via Docker |
Uses EditorConfig | EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs |
8.4.0
0.27.5
# Install dependencies
$ yarn
# Start Server
# Set environment variables defined in `config/custom-environment-variables.json` like `OPEN_WEATHER_API_KEY=xxx`
$ yarn start
# Try GET /ping to make sure server is up
$ curl http://localhost:3030/ping
# Run Tests
$ yarn test
# copy sample.dev.env to dev.env
$ cp bin/sample.dev.env bin/dev.env
# Start Server
$ bash bin/development.sh
# copy sample.test.env to test.env
$ cp bin/sample.test.env bin/test.env
# Run Tests
$ bash bin/test.sh
config is used to configure application.
config/default.json
config/test/json
for test environment.config/custom-environment-variables
is used to read values from environment variables. For ex. if APP_PORT
env var is set it can be accessed as config.get('app.port')
.You can read more on custom environment variables here.# Run lint
yarn lint
bin/sample.dev.env
in your own environment (AWS, Heroku etc) and yarn start
docker build -t hapi-starter-kit-oss .
docker run -d -p 3030:3030 --name hapi-starter-kit-oss hapi-starter-kit-oss
hapi-swagger
self documents all the APIs.http://localhost:3030/documentation
to access the documentation after starting the server.good-console
in development environment, remove it from plugins.js
Please feel free to open an issue if you can have any questions or trouble using this starter kit.
Contributions are all welcome and encouraged. For code contributions submit a pull request with unit test.
This project is licensed under the MIT License
HAPI (HL7 编程接口,发音 "happy") 是一个开源的面向对象的 HL7 2.x 解析器。 HL7 卫生信息交换标准(Health Level 7) 标准化的卫生信息传输协议,是医疗领域不同应用之间电子传输的协议。HL7汇集了不同厂商用来设计应用软件之间界面的标准格式,它将允许各个医疗机构在异构系统之间,进行数据交互。 下图是 HAPI 的一个测试工具:
A RESTful API generator rest-hapi is a hapi plugin that generates RESTful API endpoints based on mongoose schemas. It provides a powerful combination of relational structure with NoSQL flexibility. Yo
testing-hapi Example Hapi-backed API Server with testing, CI, and Swagger documentation generator. Updated and tested with latest hapi packages as of 1/16/2018. How to run Requires Node v8.12.0+ yar
Minimal Hapi + React + Webpack + HMR Sandbox This starter kit connects a hapi.js server with webpack dev server with react hot module reloading all set up. Very basic production config is also in plac
Setup $ yarn install && open http://localhost:4000 && yarn run start Medium: https://medium.com/@wesharehoodies/how-to-setup-a-powerful-api-with-nodejs-graphql-mongodb-hapi-and-swagger-e251ac189649?
ngX Starter Kit Web project starter kit including modern tools and workflow based onangular-cli, best practices from the community, a scalable base template anda good learning base. Generated using ng