miragejs / discuss

Ask questions, get help, and share what you've built with Mirage
MIT License
2 stars 0 forks source link

Question: Expose mocked API as standalone on a specific port? #49

Open ivan-dalmet opened 4 years ago

ivan-dalmet commented 4 years ago

Is there any way to expose the same mocked API on a port in NodeJS (like json-server)? (instead of calling the create server on the front app)

Like running a http.createServer in NodeJS that responds with the mock? (or an express app)

I know it's not the miragejs objective but we have a use case where we want to use it in both contexts (front app and standalone HTTP server).

Hopes there is a way to do that because we like a lot mirage :)

samselikoff commented 4 years ago

Unfortunately at this moment there is not 😔But we do have a tracking issue here:

https://github.com/miragejs/miragejs/issues/210

and it is one of our highest-priority features because (1) it makes integration with certain test runners easier and (2) it lets people test SSR'd code that makes network requests.

Hard to give an exact timeline but it's important for us.

FWIW Mirage should work in a browser-like node environment, that is in node when jsdom is present (which is why it can be used with Jest). If I had to hack something today you might be able to get something working using that. But it will be much easier soon.

ivan-dalmet commented 4 years ago

Thanks for the answer @samselikoff 🤗 Happy to see that is one of your highest-priority features 👌 I love mirage! Thanks for creating it, I will watch the releases closely 😉

MidoAhmed commented 1 year ago

Hi, thanks for this question, is it possible to run miragejs standalone with express or like webpack-dev-server ? Thanks