0.1.0 • Published 9 years ago

express-once v0.1.0

Weekly downloads
13
License
CC0-1.0
Repository
github
Last release
9 years ago

express-once

Create express middleware that just runs once.

build status coverage license version downloads

Ever wish you could make a function that would only ever be called once per request? Well now you can with once! Simple wrap your function in once and add as many times as you like to your app with the satisfcation that it will only ever be invoked... once.

var express = require('express'),
	once = require('express-once');

var app = express();

// Ensure this function is only called once
var hello = once(function middleware(req, res, next) {
	console.log('Hello world.');
});

// Try to call it many times... but it won't!
app.use(hello, hello, hello);