Slight refactor to the api module, so it will simply extend the client like it did
This commit is contained in:
27
scripts/generate/js_api/templates/api_file.tmpl
Normal file
27
scripts/generate/js_api/templates/api_file.tmpl
Normal file
@ -0,0 +1,27 @@
|
||||
var ca = require('./client_action').create;
|
||||
var errors = require('./errors');
|
||||
|
||||
var api = module.exports = {};
|
||||
|
||||
api._namespaces = <%= stringify(namespaces) %>;<%
|
||||
|
||||
_.each(actions, function (action) {
|
||||
var namespace = action.location.split('.').shift();
|
||||
if (_.contains(namespaces, namespace)) {
|
||||
_.pull(namespaces, namespace);
|
||||
var className = _.studlyCase(namespace) + 'NS';
|
||||
%>
|
||||
|
||||
api.<%= namespace %> = function <%= className %>(client) {
|
||||
if (this instanceof <%= className %>) {
|
||||
this.client = client;
|
||||
} else {
|
||||
return new <%= className %>(client);
|
||||
}
|
||||
};<%
|
||||
}
|
||||
%>
|
||||
|
||||
<%= partials.client_action(action) %><%
|
||||
|
||||
}); %>
|
||||
Reference in New Issue
Block a user