My previous post walks through the basics of JSONCV a simple JSON CV generator. Diving into the package.json (a node project, who would've guessed!) we can start looking at some of the key libraries I used --

"dependencies": {
    "body-parser": "^1.17.2",
    "cors": "^2.8.4",
    "express": "^4.15.3",
    "handlebars": "^4.0.10",
    "inliner": "^1.12.3",
    "morgan": "^1.8.2"

That may be one of the lighter dependency lists you've seen, but don't be fooled, big things come in small package (lists).

Inliner is a tool that takes a URL or URI to a HTML page and returns a document with all of the styles and scripts inlined. JSONCV is supposed to be a closed loop system, one request, one static site served. An alternative option would be to compress the static site assets into a zip file and serve this to the user, but using Inliner means we can immediately inject the HTML into an Iframe --


But wait, it get's even dirtier!

An obvious requirement of a CV generation tool is that it gives you a document that you can submit to HR when you come to apply for a job. A non-trivial solution may be to write a parser that converts json cvs to PDFs directly, though this would lead to lots of duplication given we already have a CSS theme. Option 2? Make the browser do the work for us just make our IFrame preview grab focus and try and print itself, instead saving as a PDF. Here's that dirt we were talking about --


Now a whistlestop tour of our other dependencies:

  • express, the standard web server for node
  • cors, allows cross origin requests in express (e.g. codepen -> my server)
  • handlebars, a fantastic templating language for our HTML templates
  • body-parser, express middleware to handle request bodies
  • morgan, express middleware to handle all our nasty logging bits

Checkout the source of the project over on my Github