NodeJS - Hapi & Postgres
Working through writing prototype of NodeJS Web API using Hapijs and Postgres as the backing store.
Compared to Visual Studio the process of development is so much lighter and easier. Secondly as it is light and fluid the tests are being written quickly and validating cleanly.
Choosing hapijs seems to be what is providing me all these benefits as its modularity and focus is keeping things clean and focused so far unlike Express which is more popular, but loose. I mean I could definitely write this in C# with ServiceStack, but the impediment would be the shitty experience of Visual Studio.
Using these major components so far and things are now starting to flow
Here is my current package.json file
{
"name": "prediction",
"version": "0.0.1",
"description": "Prediction Web API",
"main": "server.js",
"scripts": {
"start": "./node_modules/.bin/nodemon bootstrap.js --ignore node_modules/",
"test": "lab -R -l -v -c --coverage-path test"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"lab": "^14.1.1"
},
"dependencies": {
"babel-eslint": "^7.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"boom": "^5.2.0",
"hapi": "^16.5.0",
"joi": "^10.6.0",
"knex": "^0.13.0",
"nodemon": "^1.11.0",
"pg": "^7.0.2"
}
}
The major components are
hapijs
hapijs/lab
knex
joi
boom
babel
Working environment
- Visual Studio Code to edit files
- Terminal running
npm test
that runs the tests - Terminal running
npm start
which runs a continuously running nodemon process to catch changes immediately Postman
to run ad hoc web requests
That's all of it. The simplicity is breathtakingly fresh and clean compared to Visual Studio.