Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove heavy reliance on prototype chaining on the req/res pair #7

Merged
merged 2 commits into from
Jan 6, 2024

Conversation

joeyguerra
Copy link
Member

@joeyguerra joeyguerra commented Jan 6, 2024

feat: Upgrade to the latest path-to-regexp
BREAKING CHANGE: This design changes the Express app from a Function to a Class which has many impacts. One example is when creating the applicatio
n. This design introduces 3 main classes, ExpressApp, ExpressResponse, and ExpressRequest. The req/res pair are now instances of ExpressRequest/Response, which extend the http.IncomingMessage/ServerResponse. I tried several approaches to removing the prototype chain design, this one was the only one where I was able to successfully change the design and tests still pass (except for the ones that tested the prototypical features).

const app = express()
const server = app.listen()

Some things you used to be able do that you can no longer do are:

express.response.foo = function() { this.send('bar') }

Checkout the Exports.mjs test to see how to accomplish the same thing with the new design.

BREAKING CHANGE: Upgrading to the latest path-to-regexp breaks old routing patterns like /user/* (use /user/(.*) instead). Checkout path-to-regexp Github repo for details.

deps: Update to latest path-to-regexp
BREAKING CHANGE: Can no longer use /* (use (.*) instead) or /id:42 (use id-42 instead)
…f the request/response pair

BREAKING CHANGE: This design changes the Express app from a Function to a Class which has many impacts. One example is when creating the applicatio
n. This design introduces 3 main classes, ExpressApp, ExpressResponse, and ExpressRequest. The req/res pair are now instances of ExpressRequest/Response, which extend the http.IncomingMessage/ServerResponse. I tried several approaches to removing the prototype chain design, this one was the only one where I was able to successfully change the design and tests still pass (except for the ones that tested the prototypical features).

```javascript
const app = express()
const server = app.listen()
```

Some things you used to be able do that you can no longer do are:

```javascript
express.response.foo = function() { this.send('bar') }
```
Checkout the Exports.mjs test to see how to accomplish the same thing with the new design.
@joeyguerra joeyguerra merged commit 0c2fa05 into main Jan 6, 2024
10 checks passed
Copy link

github-actions bot commented Jan 6, 2024

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@joeyguerra joeyguerra deleted the dont-change-req-resp branch January 20, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant