express-once

0.1.0 • Public • Published

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);

Package Sidebar

Install

npm i express-once

Weekly Downloads

15

Version

0.1.0

License

CC0-1.0

Last publish

Collaborators

  • izaakschroeder