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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@braitsch/express

v1.2.7

Published

Simple boilerplate for setting up an Express.js app

Readme

@braitsch/express

Simplifies setting up an Express.js app and provides a variey of helpful utility functions.

Installation

npm i @braitsch/express

Setup

Create two files in your project's root directory:

  • app.js to initialize your app using this module
  • config.js to configure it with project specific settings

App.js

const express = require("@braitsch/express");

// create an app //

const app = express({path:__dirname, db:'transpomaps', sessions:true});

// path: to project root (required)
// db: database name (optional)
// sessions: enable sessions (optional)


// enable logging & set log directory (optional) //

express.log('./logs');

// create and start a server //
express.http(app, port);
// or //
express.https(app, port, keypath);
// 1. app: your app instance (required)
// 2. port: http defaults to 8080, https to 8443
// 3. keypath: keypath || process.env.SSL_KEY_PATH || './ssl'

Config.js

All of your custom middleware and project specific settings go in here

const busboy = require('connect-busboy');

module.exports = function(app, express) {

// attach middleware //
	app.use(busboy());
// make static assets public //
	app.use(express.static(__dirname + '/public'));
// attach your database, routers, etc //
	require(__dirname + '/server/model/database')(app);
	require(__dirname + '/server/routes/public')(app);

// if using socket.io you can easily bind req.session to a socket.io namespace //
	const wrap = middleware => (socket, next) => middleware(socket.request, {}, next);
	io.of('/namespace').use(wrap(app.sessionMiddleware));

// watch and autocompile js/css if running locally
	if (process.env.NODE_ENV == 'localhost') require('./gulpfile').watch();

}

Database.js (optional)

This module also generates a MongoDB URL if you pass a database name to express.init. It will also setup express-session for you and expose the middleware via app.sessionMiddleware if you pass true as the fourth parameter to express.init.

const MongoClient = require('mongodb').MongoClient;

module.exports = function(app) {
	MongoClient.connect(app.get('DB_URL'), {useNewUrlParser: true, useUnifiedTopology: true}, 	function(e, client) {
		if (e){
			console.log(e);
		}   else{
			const db = client.db(app.get('DB_NAME'));
		// initialize your collections here //
			log('mongo :: connected to database :: "'+app.get('DB_NAME')+'"');
		}
	});
}

Global Utility Functions

guid

generate a globally unique identifier

guid() // 2fa8de4a-6de2-4425-939e-d82e94c5261d

log

write to the console to {logdir}/app.log. initialize logging by calling express.log(logdir)

auth

basic http authentication that can be attached to any route. uses the env vars ADMIN_USER & ADMIN_PASS to authenticate which you can set inside of a .env file in your project root using dotenv.

app.get('/admin-area', auth, (req, res) => {
	// only visible if user passes http auth challenge
});

Examples

Take a look at any of the following projects for example usage:

  • https://node-login.braitsch.io/
  • https://chat.braitsch.io/
  • https://js3.braitsch.io/
  • https://doodle.braitsch.io/