Giter Club home page Giter Club logo

expressly's People

Contributors

acme avatar ddaza avatar dependabot[bot] avatar doramatadora avatar harmony7 avatar jakechampion avatar journie-fastly avatar kailan avatar marlun78 avatar triblondon avatar williamoverton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

expressly's Issues

support explicilty calling the next middleware via `next`

context

related #30

express provides a nextvariable in middlewares which represents the next middleware function in the middleware stack

see: https://expressjs.com/en/guide/using-middleware.html

this is nice to have because it allows running some code in a middleware after the middleware chain

some useful hints on implementations might be

done

  • support optional next var in middleware functions

Cannot extend the `request` object without losing type inference

Version

"@fastly/expressly": "^2.0.1"

What happened

We are having trouble trying to Type middlewares that would stub the request Object.

A common express.js pattern is to enhance the req and add new functionality to store data or add helper methods using middlewares. ie. express-session, body-parser to name a few.

We tried to do that, but we cannot find a way to Type the new methods/functionality because of the way the Request object is typed.

I opened a PR to address some of this. And would love some feedback.

Unable to catch bad requests

Version

2.0.1

What happened

We would like to be able to catch and log exceptions such as bad requests. It looks like the bad request 400 status code is returned by the runtime. Can expressly throw an error that we can catch for these requests? We are using custom error middleware and they are not catching 400s.

A bad request to an expressly service can be recreated with:

curl -svo /dev/null  "http://127.0.0.1:PORT/<"

errors not decorated with status

Version

2.0.1

What happened

Please describe what you did, what you expected to happen, and what happened instead.

When creating error middleware, the err parameter is of type Error which does not have the status property. The expressly docs mention errors would be decorated with status.

The typescript error is:

Property 'status' does not exist on type 'Error'.

feature request: access to waitUntil

The raw FetchEvent has a method waitUntil that is useful when you wish to send a response back to the client and then perform some additional async work.

Expressly does not currently (AFAIK) expose a way to use this function. It would be helpful for some use cases to expose it or something similar.

A workaround (I think) is to use the private property, but this is very ugly and hacky:

// @ts-expect-error: event is private on request
req.event.waitUntil(promise)

Expressly request streams always copy the input buffer

Version

Latest

What happened

Expressly wraps the original request in https://github.com/fastly/expressly/blob/main/src/lib/routing/request/index.ts#L17. This request wrapper effectively results in a new request created via new Request(event.request).

Per the spec, this results in copying the full input buffer and making a copy of it in guest memory - https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#input.

The issue is that this extra copy has performance implications, and in addition is currently prohibiting requests from being passed to KVStore since we don't yet support guest streams in the JS SDK, only native streams.

feature request: `res.on('finish', callback)`

Adding a callback when the request has finished would be useful for tidying up any post-request actions (e.g. sending logs/metrics/traces).

Currently we're working around this using a polling approach on res.hasEnded, but this is quite wasteful (all of the polling effort, added complexity and that after the request finishes but before the next poll the app will be sitting doing nothing).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.