Reputation: 415
I set up a few endpoints that do certain things with express. Now ideally I'd like to call them from within the node app to process some data. Is there anyway to self call the apis from within the node instance?
Upvotes: 2
Views: 2133
Reputation: 843
Maybe you can try working with Graphql (An Open Source Query Language by Facebook). This would provide a good layer of abstraction between the application and the express server.
Upvotes: 0
Reputation: 19554
It seems like you should either abstract that functionality into a library for your app (so you don't need the overhead of API calls when you're communicating data within the same instance) or use a microservice architecture with separate Express instances that call each other via HTTP. Granted, it should be possible to do this anyway by ensuring that your app knows its address and port at runtime so that one endpoint has the ability to call other endpoints.
Upvotes: 3