brillout / wildcard-api

Functions as API.
MIT License
368 stars 14 forks source link

endpoints.js not recognized when API and client are on different servers #65

Closed RyanCargan closed 3 years ago

RyanCargan commented 3 years ago

Hi, I'm currently trying to run wildcard on a two server setup and I've had no issues so far (just had to enable cors as an extra step on the backend), except that I can't seem to setup endpoints.js or *.endpoints.js files to be automatically recognized by wildcard.

From the description in the main README I assumed I could just put it next to my index.js/server.js main file on the backend and it would just work but I seem to have missed something.

Is there any way to split endpoints across multiple files without relying on the auto-recognition? Currently I'm just dumping everything in the main file and that seems to work for now.

brillout commented 3 years ago

without relying on the auto-recognition

Yes you can require() the endpoints files instead.

Let me know if that works for you.

RyanCargan commented 3 years ago

without relying on the auto-recognition

Yes you can require() the endpoints files instead.

Let me know if that works for you.

Thanks for the quick response!

I wanted check if that could cause any issues partly because I'm getting strange CPU spikes on my performance monitor with Chrome right after the client makes a call and got some browser crashes while testing with the React frontend that seemed to run fine before.

I don't know for sure whether that's connected to this (more likely a mess-up on my part). I probably shouldn't open an issue for that until after I make sure it's related to something specific.

Closing since auto-recognition doesn't seem to matter much if require() works identically.

brillout commented 3 years ago

Closing since auto-recognition doesn't seem to matter much if require() works identically.

Yes exactly, it only searches for endpoint files and then require()s them.

Let me know if you have any reproduction; I'm happy to have a closer look.

RyanCargan commented 3 years ago

Closing since auto-recognition doesn't seem to matter much if require() works identically.

Yes exactly, it only searches for endpoint files and then require()s them.

Let me know if you have any reproduction; I'm happy to have a closer look.

Just letting you know that last performance issue I mentioned was resolved (it was React-related) after making sure the client only called after a manual request or on a timer inside a useEffect hook.

No issues with the library for now. It works great. It even works if I need quick & dirty auto-refreshing data on a page but I'm guessing sockets of some sort are a better idea if I need continuous updates.

brillout commented 3 years ago

Thanks for the update :-).