npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

connect-flake

v0.1.2

Published

Connect middleware to assign a Flake ID to every request.

Downloads

10

Readme

 _______  _______  _        _        _______  _______ _________     _______  _        _______  _        _______ 
(  ____ \(  ___  )( (    /|( (    /|(  ____ \(  ____ \\__   __/    (  ____ \( \      (  ___  )| \    /\(  ____ \
| (    \/| (   ) ||  \  ( ||  \  ( || (    \/| (    \/   ) (       | (    \/| (      | (   ) ||  \  / /| (    \/
| |      | |   | ||   \ | ||   \ | || (__    | |         | | _____ | (__    | |      | (___) ||  (_/ / | (__    
| |      | |   | || (\ \) || (\ \) ||  __)   | |         | |(_____)|  __)   | |      |  ___  ||   _ (  |  __)   
| |      | |   | || | \   || | \   || (      | |         | |       | (      | |      | (   ) ||  ( \ \ | (      
| (____/\| (___) || )  \  || )  \  || (____/\| (____/\   | |       | )      | (____/\| )   ( ||  /  \ \| (____/\
(_______/(_______)|/    )_)|/    )_)(_______/(_______/   )_(       |/       (_______/|/     \||_/    \/(_______/
                                                                                                                

Connect middleware which assigns a Flake ID to every request.

Usage

$ npm install connect-flake

// load connect-flake
var flake = require('connect-flake');

// use the middleware which sets req.uuid
app.use(flake('eth0'));

// add a dynamic helper so the view can see #{uuid}
app.all(function(req, res, next) {
    res.locals.flake = req.flake;
});

Uses of a Flake ID for each Request

Log the Flake ID in your log files to help you figure out what is going on:

// in your logging
myLogger(req.flake + ' : Something bad happened.');

Tell the user the Flake ID for the failed request, and get them to use it as a reference when they report the issue to you (note: this is a Jade template):

p Your reference is '#{flake}'.

Send yourself the Flake ID of the (failed) request so you can find it quicker:

To: [email protected]
From: [email protected]
Subject: 50x error

A web request (013c7990a044-0000-08ff-00027298bef9) failed.

You may even store the requests and/or errors in your database:

sql> SELECT * FROM request WHERE uuid = '013c7990a044-0000-08ff-00027298bef9';

And there are many other uses too.

Motivation

When you have so many requests, it's hard to grep (search, find, etc) the logs to figure out what went wrong when you get a bad request. connect-flake to the rescue.

Add this module as connect middleware and each request has a Flake ID. When you log anything, make sure you log this Flake ID with it. When you get an error in your application, make sure you use the Flake ID when reporting it (whether that is logged, email or whatever). Also, tell the user (in their 50x page) what the Flake ID is when something goes wrong, so that they can tell you to sort things out.

By doing all this, you can easily find the request and what really happened to it. You may keep detailed or light logs, but either way having a direct reference to the request will really help.

Note

This package was inspired by my other package connect-uuid which was inspired by https://groups.google.com/forum/#!msg/nodejs/2NcBM7eXD94/FVm-jL91cekJ

Author

Written by Andrew Chilton - Blog - Twitter.

License

  • http://chilts.mit-license.org/2013/

(Ends)