refactor catalog code into a module so it can be invokved from node server