Try it now https://einar.io/code/MongoDB-Coding-Challenge.JS
Based on my previous experience with implementing a
solution in Haskell,
I decided to reimplement the challenge in JavaScript, because I concluded that
would have a better tool for the job all along. To improve the approachability
of the code, I thought I would implement a tiny web interface as well.
I took the opportunity to upgrade my VPS to Nginx.
The web interface is available right now on my
homepage.
I am going to assume you have already installed node.js
and npm
on your system.
Then run:
git clone git@github.com:einar-io/MongoDB-Coding-Challenge.JS.git
cd MongoDB-Coding-Challenge.JS
npm start
The tests can be run with
npm test
There are currently 11 unit tests.
The steps taken were as follows:
- Set up
node.js
project. - Create simple echo service as CLI.
- Implement the
evaluator
function for flatten. - Create web interface.
- Migrate web server form Apache2 to Nginx.
- Port the tests from Haskell to
jest
.
I consider implementing the following features:
- Add
async
/await
toitzibitzi.js
. - Dockerize the app and set up
nginx
as a reverse proxy. - Add CSS and improve the presentation of the web interface.
- Add type annotations for TypeScript.
- Add continuous integration and automatic deployment.
-
Unfortunately I did not manage to make a black-box testing of the
cli.js
. Either I need to understand Jest better, or there is a bug somewhere. The manual tests conducted did not reveal any problems. -
Jest's integration with ES6 modules seemed to be unreliable, so I went with CommonJS after some headaches.
-
JavaScript is not known for its consistent type system. This time around I learnt that:
typeof null === Object null instanceof Object === false
Do not hesitate to contact me if you have questions or need advice on how to use my solution.
Einar Rasmussen einar@einar.io LinkedIn