UNPKG

node-apis

Version:

🚀 Advanced TypeScript API generator with clean architecture, comprehensive testing, and automatic formatting. Generate production-ready Node.js APIs with complete integration test suites.

57 lines (54 loc) • 1.99 kB
"use strict"; /** * Custom API operation templates */ Object.defineProperty(exports, "__esModule", { value: true }); exports.generateCustomFileContent = exports.getCustomFileNames = void 0; /** * Gets custom API file names for a module */ const getCustomFileNames = ({ customNames, moduleName, }) => { return customNames.map(customName => `${customName}.${moduleName}.ts`); }; exports.getCustomFileNames = getCustomFileNames; /** * Generates TypeScript file content for custom API operations */ const generateCustomFileContent = ({ customName, moduleName, }) => { const capitalizedModule = moduleName.charAt(0).toUpperCase() + moduleName.slice(1); const capitalizedCustom = customName.charAt(0).toUpperCase() + customName.slice(1); // Generate operation-specific content based on common patterns return generateCustomOperationContent(customName, capitalizedModule, capitalizedCustom, moduleName); }; exports.generateCustomFileContent = generateCustomFileContent; /** * Generates custom operation content - completely generic */ const generateCustomOperationContent = (customName, capitalizedModule, capitalizedCustom, moduleName) => { return generateGenericCustomContent(customName, capitalizedModule, capitalizedCustom, moduleName); }; /** * Generates generic custom operation content */ const generateGenericCustomContent = (customName, _capitalizedModule, _capitalizedCustom, moduleName) => { return `export type typePayload = { // Define payload for ${customName} ${moduleName} id?: string; }; export type typeResultData = { // Define result data for ${customName} ${moduleName} }; export type typeResultError = { code: 'VALIDATION_ERROR' | 'NOT_FOUND' | 'UNAUTHORIZED' | 'INTERNAL_ERROR'; message: string; statusCode: 400 | 404 | 401 | 500; requestId: string; field?: string; }; export type typeResult = { data: null | typeResultData; error: null | typeResultError; }; `; }; //# sourceMappingURL=custom.templates.js.map