Peter Marklund

Peter Marklund's Home


Re-implementing this Blog again - Node.js Without Dependencies + Clojure CMS

Back in the day I originally built this blog on Ruby on Rails. I remember upgrading the app several times between different major versions of that framework. I couple of years ago I re-implemented the blog with Clojure and the Luminus web framework. I wasn't particularly impressed with Luminus but I certainly enjoyed Clojure. While working at C More last year I built an open source CMS. I also implemented a couple of APIs on Node.js where I attempted to minimize library dependencies. I found this to be a really good learning experience. As for this blog it ended up being around 1000 lines of Node.js code with zero dependencies other than Node.js itself. Obviously the majority of that code is functionality that would normally be provided by frameworks and libraries such as routing, http, templating etc. The templating code that I use is based on John Resigs Micro Templating script from 2008 with the addition of default HTML escaping and the ability to nest templates (i.e. includes).

The backend part of this blog is handled by a MongoDB based REST API with documentation provided by Swagger. That Swagger specification is used to dynamically generate an admin UI built on Vue.js. A generic admin UI is possible due to the swagger data that contains JSON schema for the blog posts model with additional metadata like which fields are relevant in the admin UI and which form fields to use etc. As a backup solution have an after save callback in my blog posts models which stores the JSON data on Dropbox.