validate api proxy with apigeelint as another proxy

Hi,

I have created node.js proxy and downloaded node module "apigeelint" into it.

package.json: { "dependencies": { "apigeelint": "" } }

I want to use this api to validate another api proxy for code analysis. Could you please help me on why proceed with this.

I could achive this by downloading node.js into local machine and install apigeelint with the below command.

>npm i -g install

And validated downloaded proxy bundle with the below command.

>apigeelint -s Proxy_path/ -f table.js

Help me on doing this process through api proxy as I asked above.

0 1 606
1 REPLY 1

I don't know apigeelint in detail, but, first let's cover some basics: if you want an API Proxy to execute some nodejs logic, then you need to

  • code the nodejs logic for an http server (you can use express if you like)
  • within the server's "event handler", execute the code you want to execute

This is standard "nodejs in Apigee Edge" stuff. You can see some of the nodejs code here.

From within the nodejs target, you cannot run a commandline command (like apigeelint). child_process.execFile won't work there. If you want to execute an external command, you may be able to do that via child_process.execFile() from within a hosted target.

I'm sorry, I recognize this may be a little confusing. I just referenced two different types of "target": node and hosted. Let me elaborate a little.

  • node target - Supported since 2015. runs within trireme. Uses node v0.10.34. Does not use ES6. Limited access to the filesystem.
  • hosted target - Currently in beta. Announced in May 2018. Runs in node v8. Uses latest node (if you like). Can use ES6. Has full access to the filesystem.

In either case you need to create a server to handle the inbound request.

If you want to run apigeelint, then you will need the client to attach the bundle to the inbound request. And then use something like the formidable module (or whatever) to retrieve the attached bundle. And then run the required logic in nodejs on that inbound file.