question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Node support tracking issue

See original GitHub issue

This issue is to track the work needed for making Mirage’s server runnable in Node. I want to write up our current thinking so that we can start to solicit feedback.

Mirage works by intercepting browser calls to fetch and XMLHttpRequst and returning a mocked HTTP response. For Node environments the approach we are taking is a bit different. Instead of intercepting all outgoing network requests from Node we will be providing a lower level APIs that allow you generate Mirage responses in user land.

For example, there will be a server.handleRequest({ method: 'GET', path: '/articles', ... }) function to generate a Mirage response for a GET /articles.

The reason for this approach is that it allows you to use a Mirage response however you see fit. It can be served from an express server or used with a node mocking library like nock. Because the use cases for running Mirage in node are much more diverse than the browser, we feel providing these lower level APIs is a good first step.

The first APIs we want to add to server:

  • canHandle(request): boolean
  • handleRequest(request): response

At this time we are unsure about the shape of the request/response objects. We will most likely look to current Mirage/Pretender and use these objects as a starting point.

Any feedback would be greatly appreciated! Thanks

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
asantos00commented, Nov 25, 2019

What about using Node’s own request object?

I’m just suggesting this because for instance express extends that object, while koa uses it directly. By supporting it we can pretty much guarantee that is going to work anywhere, don’t we?

Check out this express docs page: https://expressjs.com/en/api.html#req

The req object is an enhanced version of Node’s own request object and supports all built-in fields and methods.

0reactions
od-cyeracommented, Jul 25, 2021

Just checked, it does work, but when using typescript you cant import and use only the orm without the server. i noticed more issues with the types. might open a pr if i get the chance… anyway, thanks for the quick reply!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tracking issue: Worker support #13143 - nodejs/node - GitHub
I'm opening this as a discussion issue, as proposed in #2133 (comment), to see whether and how we can get (Web)Worker support into...
Read more >
Node Error Tracking and Performance Monitoring - Sentry
Quickly identify Node performance issues and view full end-to-end distributed trace to see the exact, poor-performing API call and surface any related errors....
Read more >
issue tracker - npm search
A simple command tool to perform common operations in a bitbucket issue tracker. It supports common operations like visualization, creation, ...
Read more >
Analytics for Node.js | Segment Documentation
Our Node.js library lets you record analytics data from your node code. ... This library uses an internal queue to make identify and...
Read more >
Node.js performance monitoring and error tracking - AppSignal
To debug Node performance problems, click on any peak in a graph, go to a performance issue, and view the event timeline. You'll...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found