29 lines
1.0 KiB
Plaintext
29 lines
1.0 KiB
Plaintext
<%
|
|
const { utils, route, config, modelTypes } = it;
|
|
const { _, pascalCase, require } = utils;
|
|
const apiClassName = pascalCase(route.moduleName);
|
|
const routes = route.routes;
|
|
const dataContracts = _.map(modelTypes, "name");
|
|
%>
|
|
|
|
<% if (config.httpClientType === config.constants.HTTP_CLIENT.AXIOS) { %> import { AxiosRequestConfig, AxiosResponse } from "axios"; <% } %>
|
|
|
|
import { HttpClient, RequestParams, ContentType, HttpResponse } from "./<%~ config.fileNames.httpClient %>";
|
|
<% if (dataContracts.length) { %>
|
|
import { <%~ dataContracts.join(", ") %> } from "./<%~ config.fileNames.dataContracts %>"
|
|
<% } %>
|
|
|
|
export class <%= apiClassName %>Api<SecurityDataType = unknown><% if (!config.singleHttpClient) { %> extends HttpClient<SecurityDataType> <% } %> {
|
|
<% if(config.singleHttpClient) { %>
|
|
http: HttpClient<SecurityDataType>;
|
|
|
|
constructor (http: HttpClient<SecurityDataType>) {
|
|
this.http = http;
|
|
}
|
|
<% } %>
|
|
|
|
<% routes.forEach((route) => { %>
|
|
<%~ includeFile('./procedure-call.ejs', { ...it, route }) %>
|
|
<% }) %>
|
|
}
|