Self teaching hapi
- query postgres for existing databases
http://localhost:8000/databases
- uses winston for logging
- log output seperated by module (auth, routes, db, logger)
- basic authentication on
http://localhost:8000/login
to receive a cookie - provides a route
http://localhost:8000/hello/{id}
available after cookie was received - replys with
hello id: 42
where 42 ist the {id} - uses swagger for api documentation
http://localhost:8000/documentation
- uses joi to verify parameters
- seperates routes in a file
/modules/routes.js
- seperates plugin in a file
/pugins/plugins.js
- swagger documentation grouped by tag
- user enviroment variables for configuration (see set_env.sh)
seperate handlers from routesmore routesauthenticationroutes with and without authenticationusing https(because its 2017!)database example- automated testing
nginx as loadbalancernot part of the appexample for multiple instancescan be handled elswhere (nginx, kubernetes)jwt integration
- Install node
git clone https://github.com/holymoly/api
cd api && npm install
node app.js
- Open http://localhost:8000/login in your browser
- Open http://localhost:8000/hello/42 in your browser
- Open http://localhost:8000/documentation in your browser
docker pull rabbitmq
docker run -d --hostname api-test --name api-test -e RABBITMQ_DEFAULT_USER=test -e RABBITMQ_DEFAULT_PASS=test -p 8080:15672 -p 1883:1883 rabbitmq:3-management
docker exec -it api-test /bin/bash
rabbitmq-plugins enable rabbitmq_mqtt
exit
2. ```
docker run -d --name some-postgres -e POSTGRES_PASSWORD=test -p 5432:5432 postgres