First steps to rewriting this using Express.js