Getting Started
npm init
npm install hapi --save
create an index.js
run
node .
hot reload
開発用, productionでは使えない
install node-dev
npm install -g node-dev
Usage
node-dev foo.js
Plugins & Default functions
Static pages and content
npm install --save inert
validation
npm install --save joi
log / good, good-console
npm install --save good
npm install --save good-console
Authentication
passport & passport-local
- Passport is authentication middleware for Node.js
- A comprehensive set of strategies support authentication using a username and password, Facebook, Twitter, and more
npm install --save passport
hapi authentication
- passport-local
- hapi-auth-cookie
- hapi-auth-jwt2
TODO check
others
- http://emptymind.me/updating-authproject-to-hapi-8-2-x/
- In this demo
isSecure
is set to false, which is a bad idea when use in a live situation - Don't forget to enable HTTPS, otherwise isSecure does not work.
- Passport-local-mongoose and mongoose are safe
- In this demo
- https://github.com/Kevin-A/AuthProject
- http://emptymind.me/user-authentication-with-hapi-passport-and-mongoose/
- http://stackoverflow.com/questions/27315146/how-to-add-simple-passport-or-basic-auth-to-hapi