EvanHahn / isExpress

given `req` and `res`, is it an Express app?

Home Page:https://www.npmjs.org/package/is-express

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

isExpress

Given req and res, is it an Express app? A simple function.

Installation:

$ npm install is-express

Usage:

var isExpress = require("is-express");

var express = require("express");
var http = require("http");

function handler(req, res) {
  if (isExpress(req)) {
    res.end("It's Express!");
  } else {
    res.end("It's not Express!");
  }
}

var expressApp = express();
expressApp.use(handler);

var httpApp = http.createServer(handler);

expressApp.listen(8000);
httpApp.listen(9000);

This isn't really intended for use in a real app -- it's more for library developers. For example, I wanted to make some middleware that acted differently if the app was built on Express.

About

given `req` and `res`, is it an Express app?

https://www.npmjs.org/package/is-express

License:The Unlicense


Languages

Language:JavaScript 100.0%