Permalink
Browse files

remove static

  • Loading branch information...
dougwilson committed Mar 6, 2014
1 parent f8a5d54 commit bb1e44f4aa1f9b21a9966227a1acce3282328e03
View
@@ -51,6 +51,7 @@ These middleware and libraries are officially supported by the Connect/Express t
- [vhost](https://github.com/expressjs/vhost) - previously `vhost`
- [csurf](https://github.com/expressjs/csurf) - previousy `csrf`
- [serve-index](https://github.com/expressjs/serve-index) - previousy `directory`
+ - [serve-static](https://github.com/expressjs/serve-static) - previously `static`
Most of these are exact ports of their Connect 2.x equivalents. The primary exception is `cookie-session`.
View
@@ -26,12 +26,6 @@ exports = module.exports = createServer;
exports.proto = proto;
-/**
- * Auto-load middleware getters.
- */
-
-exports.middleware = {};
-
/**
* Expose utilities.
*/
@@ -53,15 +47,3 @@ function createServer() {
app.stack = [];
return app;
}
-
-/**
- * Auto-load bundled middleware with getters.
- */
-
-fs.readdirSync(__dirname + '/middleware').forEach(function(filename){
- if (!/\.js$/.test(filename)) return;
- var name = basename(filename, '.js');
- function load(){ return require('./middleware/' + name); }
- exports.middleware.__defineGetter__(name, load);
- exports.__defineGetter__(name, load);
-});
View
@@ -1,87 +0,0 @@
-/*!
- * Connect - static
- * Copyright(c) 2010 Sencha Inc.
- * Copyright(c) 2011 TJ Holowaychuk
- * MIT Licensed
- */
-
-/**
- * Module dependencies.
- */
-
-var send = require('send')
- , utils = require('../utils')
- , parse = utils.parseUrl
- , url = require('url');
-
-/**
- * Static:
- *
- * Static file server with the given `root` path.
- *
- * Examples:
- *
- * var oneDay = 86400000;
- *
- * connect()
- * .use(connect.static(__dirname + '/public'))
- *
- * connect()
- * .use(connect.static(__dirname + '/public', { maxAge: oneDay }))
- *
- * Options:
- *
- * - `maxAge` Browser cache maxAge in milliseconds. defaults to 0
- * - `hidden` Allow transfer of hidden files. defaults to false
- * - `redirect` Redirect to trailing "/" when the pathname is a dir. defaults to true
- * - `index` Default file name, defaults to 'index.html'
- *
- * @param {String} root
- * @param {Object} options
- * @return {Function}
- * @api public
- */
-
-exports = module.exports = function(root, options){
- options = options || {};
-
- // root required
- if (!root) throw new Error('static() root path required');
-
- // default redirect
- var redirect = false !== options.redirect;
-
- return function staticMiddleware(req, res, next) {
- if ('GET' != req.method && 'HEAD' != req.method) return next();
- var originalUrl = url.parse(req.originalUrl);
- var path = parse(req).pathname;
-
- if (path == '/' && originalUrl.pathname[originalUrl.pathname.length - 1] != '/') {
- return directory();
- }
-
- function directory() {
- if (!redirect) return next();
- var target;
- originalUrl.pathname += '/';
- target = url.format(originalUrl);
- res.statusCode = 303;
- res.setHeader('Location', target);
- res.end('Redirecting to ' + utils.escape(target));
- }
-
- function error(err) {
- if (404 == err.status) return next();
- next(err);
- }
-
- send(req, path)
- .maxage(options.maxAge || 0)
- .root(root)
- .index(options.index || 'index.html')
- .hidden(options.hidden)
- .on('error', error)
- .on('directory', directory)
- .pipe(res);
- };
-};
View
@@ -94,16 +94,3 @@ exports.parseUrl = function(req){
return req._parsedUrl = parsed;
}
};
-
-/**
- * Normalizes the path separator from system separator
- * to URL separator, aka `/`.
- *
- * @param {String} path
- * @return {String}
- * @api private
- */
-
-exports.normalizeSlashes = function normalizeSlashes(path) {
- return path.split(sep).join('/');
-};
View
@@ -12,7 +12,6 @@
"repository": "git://github.com/senchalabs/connect.git",
"author": "TJ Holowaychuk <tj@vision-media.ca> (http://tjholowaychuk.com)",
"dependencies": {
- "send": "0.1.4",
"debug": ">= 0.7.3 < 1"
},
"devDependencies": {
@@ -1 +0,0 @@
-<p>tobi, loki, jane</p>
View
@@ -1 +0,0 @@
-I am hidden
@@ -1 +0,0 @@
-#1 file!
View
@@ -1 +0,0 @@
-baz
View
@@ -1 +0,0 @@
-123456789
View
@@ -1 +0,0 @@
-- groceries
@@ -1 +0,0 @@
-<p>tobi, loki, jane</p>
@@ -1 +0,0 @@
-ferret
Oops, something went wrong.

0 comments on commit bb1e44f

Please sign in to comment.