Browse Source

feat: use destructuring in service schematics template

pull/5137/head
Arman Ozak 6 years ago
parent
commit
cf99dd3222
  1. 22
      npm/ng-packs/packages/schematics/src/commands/api/files-service/shared/services/__namespace@dir__/__name@kebab__.service.ts.template

22
npm/ng-packs/packages/schematics/src/commands/api/files-service/shared/services/__namespace@dir__/__name@kebab__.service.ts.template

@ -1,21 +1,21 @@
<% for (let _import of imports) { <% for (const {keyword, specifiers, path} of imports) {
%><%= _import.keyword %> { <%= _import.specifiers.join(', ') %> } from '<%= _import.path %>'; %><%= keyword %> { <%= specifiers.join(', ') %> } from '<%= path %>';
<% } %> <% } %>
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class <%= name %>Service { export class <%= name %>Service {
apiName = '<%= apiName %>';<% apiName = '<%= apiName %>';<%
for (let method of methods) { %> for (let {body, signature} of methods) { %>
<%= camel(method.signature.name) %> = (<%= serializeParameters(method.signature.parameters) %>) => <%= camel(signature.name) %> = (<%= serializeParameters(signature.parameters) %>) =>
this.restService.request<<%= method.body.requestType %>, <%= method.body.responseType %>>({ this.restService.request<<%= body.requestType %>, <%= body.responseType %>>({
method: '<%= method.body.method %>', method: '<%= body.method %>',
url: `/<%= method.body.url %>`,<% url: `/<%= body.url %>`,<%
if (method.body.params.length) { %> if (body.params.length) { %>
params: { <%= method.body.params.join(', ') %> }<% } params: { <%= body.params.join(', ') %> }<% }
if (method.body.body) { %> if (body.body) { %>
body: <%= method.body.body %>,<% } %> body: <%= body.body %>,<% } %>
}, },
{ apiName: this.apiName });<% } %> { apiName: this.apiName });<% } %>

Loading…
Cancel
Save