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

lastly

v1.1.0

Published

Lightweight, no-dependency Node.js library sending a final error via POST to an absolute url.

Downloads

3

Readme

lastly

lastly is a lightweight, no-dependency Node.js library sending a final error via POST to an absolute url.

How it works

When your program encounters an uncaught exception lastly takes over. Lastly follows the same rules for error handling as process.on('uncaughtException', error => {}) so it will only handle runtime errors. If you had an error in your syntax, for example, then you'll need to fix your code the hard way! Currently, lastly will only send a POST request formatted like a Slack message. It is important to mention that if you currently have the aforementioned uncaughtException process event set up you will need to wrap that inside of lastly's callback function.

If you are sending to a Slack incoming webhook then setup is very simple. You can provide an optional callback if you want to do something with the error after lastly processes it.

It is important that lastly is configured before en error is thrown. For this reason I suggest you configure lastly as early as you can in your project

Basic setup

Lastly has only one required parameter, an absolute URI. It can optionally take a second parameter, a callback function, that will return the error that lastly processed.

const lastly = require('lastly')
lastly('https://hooks.slack.com/services/XXXXX/XXXXX/xxxxxxxxxx');

Setup with callback

const lastly = require('lastly')
lastly('https://hooks.slack.com/services/XXXXX/XXXXX/xxxxxxxxxx', (err) => {
  // Handle err
  console.error(err);
});

Setup for use with Express

If you are using the Express library you may want to handle errors that are caught by Express. To do this you'll use the error handler that lastly creates during setup and use it as middleware after all of your routes have been declared.

const lastly = require('lastly');
const express = require('express');
const PORT = process.env.PORT || 8081;

const errorHandler = lastly('https://hooks.slack.com/services/XXXXX/XXXXX/xxxxxxxxxx');

app.get('/', (_req, res) => {
  res.send('Lastly is awesome!');
});

app.use(errorHandler);

app.listen(PORT, () => console.log(`Listening on port ${PORT}...`));