Skip to content

Commit

Permalink
fix: register params validation
Browse files Browse the repository at this point in the history
  • Loading branch information
aaitor committed Mar 6, 2024
1 parent e25b1e3 commit 5575d23
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nevermined-io/cli",
"version": "2.1.0",
"version": "2.1.1",
"main": "index.js",
"repository": "[email protected]:nevermined-io/cli.git",
"author": "Nevermined",
Expand Down
1 change: 1 addition & 0 deletions resources/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -2139,6 +2139,7 @@
{
"name": "endpoint",
"type": "array",
"default": [],
"demandOption": true,
"description": "Endpoint where the agent is available. The format is method@url. Example: --endpoint GET@http://example.com/get/(.*)"
},
Expand Down
11 changes: 8 additions & 3 deletions src/commands/app/registerAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export const registerAgent = async (
logger.info(chalk.dim(`Registering Agent ...`))

logger.debug(chalk.dim(`Using publisher account: '${publisherAccount.getId()}'\n`))

if (argv.name === '' || argv.endpoint === '') {

const paramEndpoints: string[] = argv.endpoint

if (argv.name === '' || paramEndpoints.length < 1) {
return {
status: StatusCodes.ERROR,
errorMessage: `The following parameters need to be given: name, endpoint`
Expand Down Expand Up @@ -53,7 +55,10 @@ export const registerAgent = async (
}

const endpoints: { [verb: string]: string }[] = []
argv.endpoint.map((e: string) => {

paramEndpoints.map((_e: string) => {
const e = new String(_e)

if (e.split('@').length >= 2) {
const [verb, url] = e.split('@')
endpoints.push({ [verb.toLocaleUpperCase()]: url })
Expand Down

0 comments on commit 5575d23

Please sign in to comment.