MCPcopy Create free account
hub / github.com/acode/cli / generateFunction

Function generateFunction

cli/commands/endpoints/create.js:11–34  ·  view source on GitHub ↗
(name, description, params)

Source from the content-addressed store, hash-verified

9const chalk = require('chalk');
10
11function generateFunction(name, description, params) {
12
13 params = (params || []).map(p => {
14 p = p.split(':');
15 return {
16 name: p[0],
17 type: p[1] || 'any'
18 };
19 });
20
21 return [
22 '/**',
23 description ? `* ${description}` : '',
24 params.map(param => {
25 return `* @param {${param.type}} ${param.name}`
26 }).join('\n'),
27 `* @returns {any}`,
28 `*/`,
29 `module.exports = async (${params.map(p => p.name).concat('context').join(', ')}) => {`,
30 ` return 'output of new endpoint: ${name}';`,
31 `};`,
32 ].filter(v => !!v).join('\n') + '\n';
33
34}
35
36class EndpointsCreateCommand extends Command {
37

Callers 1

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected