1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-12 10:52:47 +00:00

updated bunch of file paths and changed the way posts are loaded

This commit is contained in:
2016-01-05 12:28:04 -06:00
parent 4bb8cae81e
commit 6ab45fe935
13249 changed files with 317868 additions and 2101398 deletions

View File

@@ -1,14 +1,34 @@
/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
'use strict';
/**
* Module dependencies.
* @private
*/
var debug = require('debug')('express:router:route');
var flatten = require('array-flatten');
var Layer = require('./layer');
var methods = require('methods');
var utils = require('../utils');
/**
* Expose `Route`.
* Module variables.
* @private
*/
var slice = Array.prototype.slice;
var toString = Object.prototype.toString;
/**
* Module exports.
* @public
*/
module.exports = Route;
@@ -17,20 +37,22 @@ module.exports = Route;
* Initialize `Route` with the given `path`,
*
* @param {String} path
* @api private
* @public
*/
function Route(path) {
debug('new %s', path);
this.path = path;
this.stack = [];
debug('new %s', path);
// route handlers for various http methods
this.methods = {};
}
/**
* @api private
* Determine if the route handles a given method.
* @private
*/
Route.prototype._handles_method = function _handles_method(method) {
@@ -38,18 +60,18 @@ Route.prototype._handles_method = function _handles_method(method) {
return true;
}
method = method.toLowerCase();
var name = method.toLowerCase();
if (method === 'head' && !this.methods['head']) {
method = 'get';
if (name === 'head' && !this.methods['head']) {
name = 'get';
}
return Boolean(this.methods[method]);
return Boolean(this.methods[name]);
};
/**
* @return {Array} supported HTTP methods
* @api private
* @private
*/
Route.prototype._options = function _options() {
@@ -70,11 +92,10 @@ Route.prototype._options = function _options() {
/**
* dispatch req, res into this route
*
* @api private
* @private
*/
Route.prototype.dispatch = function(req, res, done){
Route.prototype.dispatch = function dispatch(req, res, done) {
var idx = 0;
var stack = this.stack;
if (stack.length === 0) {
@@ -140,44 +161,50 @@ Route.prototype.dispatch = function(req, res, done){
* @api public
*/
Route.prototype.all = function(){
var callbacks = utils.flatten([].slice.call(arguments));
callbacks.forEach(function(fn) {
if (typeof fn !== 'function') {
var type = {}.toString.call(fn);
Route.prototype.all = function all() {
var handles = flatten(slice.call(arguments));
for (var i = 0; i < handles.length; i++) {
var handle = handles[i];
if (typeof handle !== 'function') {
var type = toString.call(handle);
var msg = 'Route.all() requires callback functions but got a ' + type;
throw new Error(msg);
throw new TypeError(msg);
}
var layer = Layer('/', {}, fn);
var layer = Layer('/', {}, handle);
layer.method = undefined;
this.methods._all = true;
this.stack.push(layer);
}, this);
}
return this;
};
methods.forEach(function(method){
Route.prototype[method] = function(){
var callbacks = utils.flatten([].slice.call(arguments));
var handles = flatten(slice.call(arguments));
callbacks.forEach(function(fn) {
if (typeof fn !== 'function') {
var type = {}.toString.call(fn);
for (var i = 0; i < handles.length; i++) {
var handle = handles[i];
if (typeof handle !== 'function') {
var type = toString.call(handle);
var msg = 'Route.' + method + '() requires callback functions but got a ' + type;
throw new Error(msg);
}
debug('%s %s', method, this.path);
var layer = Layer('/', {}, fn);
var layer = Layer('/', {}, handle);
layer.method = method;
this.methods[method] = true;
this.stack.push(layer);
}, this);
}
return this;
};
});