route-type.ejs 732 B

12345678910111213141516171819202122
  1. <%
  2. const { route, utils, config } = it;
  3. const { _, pascalCase, require } = utils;
  4. const { query, payload, pathParams, headers } = route.request;
  5. const routeDocs = includeFile("./route-docs", { config, route, utils });
  6. const routeNamespace = pascalCase(route.routeName.usage);
  7. %>
  8. /**
  9. <%~ routeDocs.description %>
  10. <%~ routeDocs.lines %>
  11. */
  12. export namespace <%~ routeNamespace %> {
  13. export type RequestParams = <%~ (pathParams && pathParams.type) || '{}' %>;
  14. export type RequestQuery = <%~ (query && query.type) || '{}' %>;
  15. export type RequestBody = <%~ (payload && payload.type) || 'never' %>;
  16. export type RequestHeaders = <%~ (headers && headers.type) || '{}' %>;
  17. export type ResponseBody = <%~ route.response.type %>;
  18. }