Moved js code generation into the service