A Hapi server with anything and everything thrown in.
A playground for Hapi.
A place to test frontend libraries and frameworks.
To use as a test bed for all the wonderful things Hapi (and its plugins) offer.
To compare frontend libraries and frameworks acting on the same data.
- Hapi users/groups API
- Logging to Loggly
- Persistance to MongoDB
- Relationships stored in OrientDB
- Testing with Ava
- TODO: Caching (and key-value storage) with Redis and Catbox
- TODO: RethinkDB
It's easy to create a Hapi server with basic routes, better still is to pull functionality into modules, both Hapi modules (route logic and orchestration) and business modules (CRUD and business rules for domain objects).
Create the same application in multiple libaries/frameworks to compare them.
- A React app using Material UI
I'll aim to use modern techniques as much as possible.
This started out on Node 4. Now we're on Node 6 and the need for transpiling the API code has lessened.
The frontend apps are stand-alone so any transformation can be done as and when.
AVA comes bundled with Babel so I've jumped straight into using ES7 features, namely async
/await
.
- No semi-colons
- Lambdas
- Functional (Or at least some facets of functional programming)
- ES2015 as much as possible, even for the web apps
- Favour
const
overlet
and more so overvar
- Tabs over spaces!
- Comment liberally - Why? - Because this is a learning experience and the more explanations alongside the code the better - Maybe
- Code that acts as its own comment. Namely descriptive names for functions and variables
- Fire up Mongo
mongod
(version 3.2.4) - Fire up OrientDB
cd path/to/orientdb/bin/
then./server.sh
(version 2.1.16) - Fire up Redis
redis-server
- Run
npm start
to get the API running here - View request debugging
- Run
npm run serve:react-mui
to startwebpack-dev-server
and browse to here
API tests are run using AVA.
The helper file api.js makes requests to a running server. I thought about using Hapi's server.inject()
, which I've used in the past, but I'm holding off on that to see if I miss it.
I'm a wannabe fan of CodeceptJS, I've yet to use it in anger, but I've liked what I've seen of it from the little I've used it.
CodeceptJS is an abstruction over WebdriverIO, which itself sits on top of Selenium, a running version of which is needed to run the CJS tests.
Notes:
brew install selenium-server-standalone
and start withselenium-server -p 4444
. Then ine2e
folder,run codeceptjs run --steps
.- CodeceptJS, or maybe it's Webdriver(IO), doesn't complain if Selenium isn't started.
- Install with
brew install redis
- Start with
redis-server
- The default port is 6379
- Check Redis is running with
redis-cli ping
or simplyredis-cli
. The former doesn't drop you into the CLI, the latter does. - Stop Redis with
Ctrl + C
- Run
redis-cli INFO keyspace
to list "databases"
Work on this for at least 30 minutes a day. No excuses!
Well that didn't happen! Here for prosperity...
Starting on Wednesday 3rd of February:
- Day 1 - Project set-up: git, npm, readme - Server set-up: Hapi, routes, documentation
- Day 2 - CRUD for users
- Day 2.5 - Move CRUD into user object to simplify the routes
- Day 3 - Create Users Hapi plugin - Add logging and send to Loggly
- Day 4 - Added groups to graph
Next: Serve nested groups