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

baritone

v8.3.0

Published

A barebone express server

Downloads

146

Readme

#Baritone

A barebone express server.

Baritone is a superset of express. You can use Baritone as if it is an express instance, including all express methods. The only method Baritone overrides is render

##Why?

Because express still has a lot of boiler plate, as well as some common problems to overcome.

###Boiler plate?

  • Config setup
  • Common middleware such as static, compress
  • Starting a server with proper logging

###Common problems?

  • All modules sharing the same config. Discussed in further detail in Baritone.app()
  • Code organization. Discussed in further detail in Baritone.import()

##Quick start

var baritone = require('baritone');

// retrieve a shared baritone (express) instance
var app = baritone.app();

// import the config, middleware, and routes of the base directory and baritone
app.import('.', 'baritone');

// start a server at the default host and port
app.start();

##Static Methods

###Baritone.app()

Retrieves the shared baritone instance, effectively turning express into a singleton. All modules that use baritone.app() will interface with the same underlying express app.

This is different than how invoking express() directly works. Invoking express() always gives you a new express instance. However, this can be unwanted behavior if you want share an express instance among separate modules. Without Baritone, sharing the same express instance was acheived through circular dependencies or globals. Globals are usually frowned upon, and while circular dependencies are supported in node, they can get a little hairy.

##Instance Methods

###baritone.import(...paths)

Attempts to require ./routes, ./middleware, and ./config within each path provided. A path can also be an npm module. For example, in your own app you'll want to import('baritone') to load in baritone's default routes, middleware, and config. Using import('.') will load the routes, middleware, and config from the main app's directory.

This design promotes breaking your app into smaller parts based on purpose. For example, you might have an accounts directory that includes the routes, middleware, and config associated with accounts.

###baritone.start()

Starts a web server. The host and port are retrieved from the config. By default this is 0.0.0.0 and 3000 respectively. You can change these values by importing your own config file or setting PORT and HOST environment variables.

###bartione.pjax(req, res, view)

If the request is an XHR, it responds with the {view: view, data: res.locals}. If the request is not an XHR, it will send the html file set by the html config option. It's up to your client code to retrieve view modules via XHR based on the current URL. Note that this method calls res.send(), effectively ending the request for you.