简体   繁体   中英

How do I trigger a node.js code from local?

I would like to get info from an app and process it using node.js. Can I write the script and have it locally and trigger it using some apps like mule api? or I should use some server like AWS to deploy the node.js code?

Set up an HTTP server with node, there are plenty of ways to do that (For example, the built-in http module or expressjs ) then send an HTTP request to it using the Fetch API (assuming we are talking about a browser communicating with it).

About deploying it - heavily depends on your preference and needs, but that shouldn't change how you communicate with it.

You could technically, but you should always let the server listening for some events on your machine, which is not ideal if you don't own a server. A better solution would be to deploy your script and trigger it in the way that it's more convenient to you. It may be an HTTP request for example. AWS is great, but if you don't want to spend too much time configuring stuff I'd suggest Heroku.

Can I write the script and have it locally and trigger it using some apps like mule api?

The blurb for Mule API says it supports on-premise systems, so yes.

or I should use some server like AWS to deploy the node.js code?

That's a matter of opinion.

Using cloud hosting will:

  • Save you from having to maintain the hardware that it runs on (including such things as making sure the computer doesn't get switched off)
  • Make security for the app more complicated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM