express-once
v0.1.0
Published
Create express middleware that just runs once.
Downloads
97
Maintainers
Readme
express-once
Create express middleware that just runs once.
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);