How to use the connect.errorHandler function in connect

To help you get started, we’ve selected a few connect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ALT-F1 / nodejs-professional / chap_20-HTTP_Middleware / errorHandler.js View on Github external
console.log("I am listening to this port: http://localhost:%s", PORT_LISTENER);

var connect = require('connect');
var app = connect();

connect.errorHandler.title = 'My Application';

app.use(function(req, res, next) {
	next(new Error('Hey!'));
});
// actually respond
app.use(function(req, res) {
	res.end('Hello World!');
});
app.use(connect.errorHandler());
app.listen(PORT_LISTENER);
github facebook / watchman / website / server / server.js View on Github external
static: true
};

var app = connect()
  .use(function(req, res, next) {
    // convert all the md files on every request. This is not optimal
    // but fast enough that we don't really need to care right now.
    convert();
    next();
  })
  .use(reactMiddleware.provide(buildOptions))
  .use(connect['static'](FILE_SERVE_ROOT))
  .use(connect.favicon(path.join(FILE_SERVE_ROOT, 'watchman', 'img', 'favicon.png')))
  .use(connect.logger())
  .use(connect.compress())
  .use(connect.errorHandler());

var portToUse = port || 8080;
var server = http.createServer(app);
server.listen(portToUse);
console.log('Open http://localhost:' + portToUse + '/watchman/index.html');
module.exports = server;
github facebook / jest / website / server / server.js View on Github external
.use('/jest/blog/feed.xml', (req, res) => {
    res.end(
      fs.readFileSync(path.join(FILE_SERVE_ROOT, 'jest/blog/feed.xml')) + ''
    );
  })
  .use('/jest/blog/atom.xml', (req, res) => {
    res.end(
      fs.readFileSync(path.join(FILE_SERVE_ROOT, 'jest/blog/atom.xml')) + ''
    );
  })
  .use(reactMiddleware.provide(buildOptions))
  .use(connect['static'](FILE_SERVE_ROOT))
  // .use(connect.favicon(path.join(FILE_SERVE_ROOT, 'elements', 'favicon', 'favicon.ico')))
  .use(connect.logger())
  .use(connect.compress())
  .use(connect.errorHandler());

const portToUse = port || 8080;
const server = http.createServer(app);
server.listen(portToUse);
console.log('Open http://localhost:' + portToUse + '/jest/index.html');
module.exports = server;
github root-two / react-native-drawer / examples / RNDrawerDemo / node_modules / react-native / packager / packager.js View on Github external
var app = connect()
    .use(loadRawBody)
    .use(openStackFrameInEditor)
    .use(getDevToolsLauncher(options))
    .use(statusPageMiddleware)
    // Temporarily disable flow check until it's more stable
    //.use(getFlowTypeCheckMiddleware(options))
    .use(getAppMiddleware(options));

  options.projectRoots.forEach(function(root) {
    app.use(connect.static(root));
  });

  app.use(connect.logger())
    .use(connect.compress())
    .use(connect.errorHandler());

  return http.createServer(app).listen(options.port, '::', readyCallback);
}
github jaystack / jaydata / test / qunit / test_Node.js View on Github external
var paths = files.map(function (p) {
                    return path.join(process.cwd(), p);
                });
                nodeunit.runFiles(paths, opts);
            } else {
                nodeunit.runModules(files, opts);
            }
        }
    };
    reporter.run(exports, null, function (err) {
        if (err) next(err);
        else res.end();
    });
});

app.use(connect.errorHandler());

$data.Class.define('$exampleSrv.ComplexT', $data.Entity, null, {
    Name: { type: 'string' },
    Description: { type: 'string' },
    Age: { type: 'int' },
    Created: { type: 'date' }
});

$data.Class.define('$exampleSrv.ComplexTWithComplex', $data.Entity, null, {
    Title: { type: 'string' },
    Complex: { type: '$exampleSrv.ComplexT' }
});

$data.Class.define('$exampleSrv.ComplexTWithArrayComplex', $data.Entity, null, {
    Title: { type: 'string' },
    Complex: { type: 'Array', elementType: '$exampleSrv.ComplexT' }
github jaystack / jaydata / test / qunit / scripts / NodeJS / LStestservice.js View on Github external
});

/*app.use(connect.basicAuth(function (user, pass) {
    return 'asd' == user & 'asd' == pass;
}));*/

app.use(connect.query());
app.use(connect.bodyParser());
app.use($data.JayService.OData.Utils.simpleBodyReader());

app.use("/", connect.static("/home/borzav/sf/jay/jaydata"));
app.use("/testservice", $data.JayService.createAdapter(Context, function () {
    return new Context({ name: 'mongoDB', databaseName: 'LSTestDb', responseLimit: -1 });
}));

app.use(connect.errorHandler());

app.listen(3001);
github gvnn / flatwhite / src / flatwhite.js View on Github external
app.get(_path, function(req, res, next) {
            loader("get", req, res, next);
        });
        //Put -> Update
        app.put(_path, function(req, res, next) {
            loader("put", req, res, next);
        });
        //Delete -> Delete
        app.del(_path, function(req, res, next) {
            loader("delete", req, res, next);
        });
    })
);

//Uncaught Exceptions
server.use(connect.errorHandler({ showStack: config.errors.showStack, dumpExceptions: config.errors.dumpExceptions }));

//start server
server.listen(config.server.port);
utils.log("flatwhite started on port " + config.server.port);
github tsyeyuanfeng / metro-bundler-cli / local-cli / server / runServer.js View on Github external
connect.static(path.join(__dirname, 'util', 'debugger-ui')),
    )
    .use(
      getDevToolsMiddleware(args, () => wsProxy && wsProxy.isChromeConnected()),
    )
    .use(getDevToolsMiddleware(args, () => ms && ms.isChromeConnected()))
    .use(openStackFrameInEditorMiddleware(args))
    .use(copyToClipBoardMiddleware)
    .use(statusPageMiddleware)
    .use(systraceProfileMiddleware)
    .use(indexPageMiddleware)
    .use(packagerServer.processRequest.bind(packagerServer));

  args.projectRoots.forEach(root => app.use(connect.static(root)));

  app.use(connect.logger()).use(connect.errorHandler());

  if (args.https && (!args.key || !args.cert)) {
    throw new Error('Cannot use https without specifying key and cert options');
  }

  const serverInstance = args.https
    ? https.createServer(
        {
          key: fs.readFileSync(args.key),
          cert: fs.readFileSync(args.cert),
        },
        app,
      )
    : http.createServer(app);

  serverInstance.listen(args.port, args.host, 511, function() {
github leecade / react-native-swiper / examples / node_modules / react-native / packager / packager.js View on Github external
) {
  var app = connect()
    .use(loadRawBody)
    .use(openStackFrameInEditor)
    .use(getDevToolsLauncher(options))
    .use(statusPageMiddleware)
    .use(getFlowTypeCheckMiddleware(options))
    .use(getAppMiddleware(options));

  options.projectRoots.forEach(function(root) {
    app.use(connect.static(root));
  });

  app.use(connect.logger())
    .use(connect.compress())
    .use(connect.errorHandler());

  return http.createServer(app).listen(options.port, '::', readyCallback);
}
github nko / done-js / app.js View on Github external
app.configure('development', function(){
  app.use(connect.errorHandler({ dumpExceptions: true, showStack: true })); 
});