Router.js — express Source File
Architecture documentation for Router.js, a javascript file in the express codebase.
Entity Profile
Source Code
'use strict'
var after = require('after');
var express = require('../')
, Router = express.Router
, methods = require('../lib/utils').methods
, assert = require('node:assert');
describe('Router', function () {
it('should return a function with router methods', function () {
var router = new Router();
assert(typeof router === 'function')
assert(typeof router.get === 'function')
assert(typeof router.handle === 'function')
assert(typeof router.use === 'function')
});
it('should support .use of other routers', function (done) {
var router = new Router();
var another = new Router();
another.get('/bar', function (req, res) {
res.end();
});
router.use('/foo', another);
router.handle({ url: '/foo/bar', method: 'GET' }, { end: done }, function () { });
});
it('should support dynamic routes', function (done) {
var router = new Router();
var another = new Router();
another.get('/:bar', function (req, res) {
assert.strictEqual(req.params.bar, 'route')
res.end();
});
router.use('/:foo', another);
router.handle({ url: '/test/route', method: 'GET' }, { end: done }, function () { });
});
it('should handle blank URL', function (done) {
var router = new Router();
router.use(function (req, res) {
throw new Error('should not be called')
});
router.handle({ url: '', method: 'GET' }, {}, done);
});
it('should handle missing URL', function (done) {
var router = new Router()
router.use(function (req, res) {
throw new Error('should not be called')
})
// ... (577 more lines)
Source
Frequently Asked Questions
What does Router.js do?
Router.js is a source file in the express codebase, written in javascript.
Where is Router.js in the architecture?
Router.js is located at test/Router.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free