Git Product home page Git Product logo

fastify-racing's Introduction

  • ๐Ÿ‘‹ Hi, Iโ€™m @metcoder95
  • ๐Ÿ“ซ How to reach me - Feel free to reach me for any topic, question, support, and so on.

fastify-racing's People

Contributors

dependabot[bot] avatar metcoder95 avatar

Stargazers

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

Watchers

 avatar  avatar

fastify-racing's Issues

Trying to understand the weakmap

Sorry for raising an issue with a question, couldn't find any other communication means. I'm trying to understand why this is using a WeakMap to store the controllers instead of storing them in Fastify's request context.

Requesting to be passed the original Fastify request object in callback

Feature Request:
Pass back the original Fastify request when invoking the callback.

Details:
I'd like to use a single default onRequestClosed callback to handle all aborted requests. When this callback is invoked, I'd like to have access to the underlying Fastify request object if possible.

Alternatively, maybe there is a way to use this plugin in combination with Fastify's built-in request lifecycle hooks to achieve a similar result. (If this works, maybe a quick example in the docs would be helpful to others heading down a similar path)

Background
Fastify provides separate request/response logging out-of-the-box. In our environment, we found by combining the request / response logs - troubleshooting issues based on log data was much easier. Overall this approach works well, but I recently discovered that our current approach will not log request information during a client abort. (This is how I eventually discovered fastify-racing plugin....thanks!)

Our current logging setup:

fastifyInstance.addHook("onRequest", (req, reply, done) => {
    // track overall response time
    reply.startTime = Date.now();
    done();
});


// use hook based logging instead of internal logger to provide a single
// combined log message per-request, instead of the default request/reply
// logging
fastifyInstance.addHook('onResponse', (req: FastifyRequest, res: FastifyReply) => {
    if (req.url === healthEndpoint) {
        logger.info({
            req,
            res
        });
    } else {
        logger.info({
            req,
            res
        });
    }
});

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.