Skip to content

Development server based on Express for debugging your server-side routes

License

Notifications You must be signed in to change notification settings

travishuff/Express-Monocle

 
 

Repository files navigation

Express Monocle

A developer tool for debugging your server-side routes

Description

Express Monocle forks the popular Node server library, express, and adds easy-to-use degugging functionality for developers. You can track the changes to the request and response objects as they make their way through server routes in order to easily find out how and when the objects change.

We inject ES6 proxies into the request and response object constructors to easily track changes.

We also implemented an automatic debugging route to visualize those changes called '/debug' to see exactly what's going on.

Installation

$ npm install express-monocle

Usage

const em = require('express-monocle');
const path = require('path');
const bodyParser = require('body-parser');

const app = em();

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

app.get('/', function (req, res, next) {
  res.sendFile(path.join(__dirname, 'index.html'));
});

app.post('/signup', function checkIfUserExist(req, res, next) {
  req.user = {
    username: 'hello',
    password: 'world'
  };
  next();
}, function setCookieId(req, res, next) {
  res.cookie = { token: '32432kd9a01232' };
  next();
}, function (req, res, next) {
  res.redirect('/home');
});

app.get('/home', function (req, res) {
  res.sendFile(path.join(__dirname, 'home.html'));
});

app.listen(3000);

Screenshot of debugging route: Express-Monocle

Authors

Cheng Ly
Travis Huff
Patrick Divine
Sahil Nayak

Access your routes and then go to /debug to see all the changes.

License

MIT

About

Development server based on Express for debugging your server-side routes

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • JavaScript 94.4%
  • HTML 5.4%
  • Other 0.2%