javascript: Common API code generation refactored