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 🙏

© 2025 – Pkg Stats / Ryan Hefner

donejs-error-format

v1.2.0

Published

[![Build Status](https://travis-ci.org/donejs/donejs-error-format.svg?branch=master)](https://travis-ci.org/donejs/donejs-error-format) [![npm version](https://badge.fury.io/js/donejs-error-format.svg)](http://badge.fury.io/js/donejs-error-format)

Readme

donejs-error-format

Build Status npm version

An error formatter for Errors that are emitted by done-ssr.

Install

npm install donejs-error-format --save

Usage

If you are using done-serve, it already uses donejs-error-format internally. If you use done-ssr or done-ssr-middleware, you can use this module to format your error messages.

done-ssr

const errorFormat = require("donejs-error-format");
const ssr = require("done-ssr");

const render = ssr({ config: __dirname + "/package.json" });

function app(request, response) {
	// More stuff here, obviously, like static assets, etc.

	let stream = render(request);

	stream.on("error", function(error){
		let parts = errorFormat.extract(error);
		let html = errorFormat.html(parts);

		console.error(error);

		response.writeHead(200, { type: "text/html" });
		response.end(html);
	});

	stream.pipe(response);
}

require("http").createServer(app).listen(8080);

done-ssr-middleware

const express = require("express");
const errorFormat = require("donejs-error-format");
const ssr = require("done-ssr-middleware");

const app = express();

app.use(express.static(__dirname + "/public"));

app.use(ssr({ config: __dirname + "/package.json!npm" }));


// The last middleware should be the error handler
app.use(function(error, request, response, next) {
	let parts = errorFormat.extract(error);
	let html = errorFormat.html(parts);

	console.error(error);

	response.type("html").end(html);
});

API

.extract(error)

This function takes an Error and returns an object with parts extracted. This is used to pass into .html() and other formatting functions (currently there is only HTML).

.html(parts)

This function is used to generate formatted HTML. It takes a parts object that comes from using .extract.

let parts = errorFormat.extract(error);
let html = errorFormat.html(parts);

.html(parts, options)

The second signature is like the first but takes an options object. The options are:

  • liveReload: This can either be the boolean true or an object that provides the port like: { port: 4044 }. By default the port 8012 is used (which is the default in DoneJS apps). You only need to set this option if you are using an alternative port in your development server.

Enabling the live-reload script:

let parts = errorFormat.extract(error);
let html = errorFormat.html(parts, {
	liveReload: true
})

Or with a port:

let parts = errorFormat.extract(error);
let html = errorFormat.html(parts, {
	liveReload: {
		port: 4044
	}
})

License

MIT