Detalhes do pacote

express3-handlebars

ericf427depreciado0.5.2

THIS PACKAGE HAS BEEN RENAMED TO: express-handlebars

A Handlebars view engine for Express which doesn't suck.

express, express3, handlebars, view

readme (leia-me)

RENAMED TO: express-handlebars

This package has been renamed to express-handlebars, be sure to update your package.json files.

See: https://www.npmjs.org/package/express-handlebars


Express3 Handlebars

A Handlebars view engine for Express which doesn't suck.

Dependency Status

Goals & Design

I created this project out of frustration with the existing Handlebars view engines for Express. As of version 3.x, Express got out of the business of being a generic view engine — this was a great decision — leaving developers to implement the concepts of layouts, partials, and doing file I/O for their template engines of choice.

Goals and Features

After building a half-dozen Express apps, I developed requirements and opinions about what a Handlebars view engine should provide and how it should be implemented. The following is that list:

  • Add back the concept of "layout", which was removed in Express 3.x.

  • Add back the concept of "partials" via Handlebars' partials mechanism.

  • Support a directory of partials; e.g., {{> foo/bar}} which exists on the file system at views/partials/foo/bar.handlebars by default.

  • Smart file system I/O and template caching. When in development, templates are always loaded from disk. In production, raw files and compiled templates are cached, including partials.

  • All async and non-blocking. File system I/O is slow and servers should not be blocked from handling requests while reading from disk. I/O queuing is used to avoid doing unnecessary work.

  • Ability to expose precompiled templates and partials to the client, enabling template sharing and reuse.

  • Ability to use a different Handlebars module/implementation other than the Handlebars npm package.

Package Design

This package was designed to work great for both the simple and complex use cases. I intentionally made sure the full implementation is exposed and is easily overrideable.

The package exports a function which can be invoked with no arguments or with a config object and it will return a function (closed over sane defaults) which can be registered with an Express app. It's an engine factory function.

This exported engine factory has two properties which expose the underlying implementation:

  • ExpressHandlebars(): The constructor function which holds the internal implementation on its prototype. This produces instance objects which store their configuration, compiled and precompiled templates, and expose an engine() function which can be registered with an Express app.

  • create(): A convenience factory function for creating ExpressHandlebars instances.

An instance-based approach is used so that multiple ExpressHandlebars instances can be created with their own configuration, templates, partials, and helpers.

Installation

Install using npm:

$ npm install express3-handlebars

Usage

This view engine uses sane defaults that leverage the "Express-way" of structuring an app's views. This makes it trivial to use in basic apps:

Basic Usage

Directory Structure:

.
├── app.js
└── views
    ├── home.handlebars
    └── layouts
        └── main.handlebars

2 directories, 3 files

app.js:

Creates a super simple Express app which shows the basic way to register a Handlebars view engine using this package.

var express = require('express'),
    exphbs  = require('express3-handlebars'),

    app = express();

app.engine('handlebars', exphbs({defaultLayout: 'main'}));
app.set('view engine', 'handlebars');

app.get('/', function (req, res) {
    res.render('home');
});

app.listen(3000);

views/layouts/main.handlebars:

The main layout is the HTML page wrapper which can be reused for the different views of the app. {{{body}}} is used as a placeholder for where the main content should be rendered.

<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Example App</title>
</head>
<body>

    {{{body}}}

</body>
</html>

views/home.handlebars:

The content for the app's home view which will be rendered into the layout's {{{body}}}.

<h1>Example App: Home</h1>

Running the Example

The above example is bundled in this package's examples directory, where it can be run by:

$ cd examples/basic/ && node app

Using Instances

Another way to use this view engine is to create an instance(s) of ExpressHandlebars, allowing access to the full API:

var express = require('express'),
    exphbs  = require('express3-handlebars'),

    app = express(),
    hbs = exphbs.create({ /* config */ });

// Register `hbs.engine` with the Express app.
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');

// ...still have a reference to `hbs`, on which methods like `loadPartials()`
// can be called.

Note: The Advanced Usage example demonstrates how ExpressHandlebars instances can be leveraged.

Template Caching

This view engine uses a smart template caching strategy. In development, templates will always be loaded from disk, i.e., no caching. In production, raw files and compiled Handlebars templates are aggressively cached.

The easiest way to control template/view caching is through Express' view cache setting:

app.enable('view cache');

Express enables this setting by default when in production mode, i.e., process.env.NODE_ENV === "production".

Note: All of the public API methods accept options.cache, which gives control over caching when calling these methods directly.

Layouts

A layout is simply a Handlebars template with a {{{body}}} placeholder. Usually it will be an HTML page wrapper into which views will be rendered.

This view engine adds back the concept of "layout", which was removed in Express 3.x. It can be configured with a path to the layouts directory, by default it's set to "views/layouts/".

There are two ways to set a default layout: configuring the view engine's defaultLayout property, or setting Express locals app.locals.layout.

The layout into which a view should be rendered can be overridden per-request by assigning a different value to the layout request local. The following will render the "home" view with no layout:

app.get('/', function (req, res, next) {
    res.render('home', {layout: false});
});

Helpers

Helper functions, or "helpers" are functions that can be registered with Handlebars and can be called within a template. Helpers can be used for transforming output, iterating over data, etc. To keep with the spirit of logic-less templates, helpers are the place where logic should be defined.

Handlebars ships with some built-in helpers, such as: with, if, each, etc. Most application will need to extend this set of helpers to include app-specific logic and transformations. Beyond defining global helpers on Handlebars, this view engine supports ExpressHandlebars instance-level helpers via the helpers configuration property, and render-level helpers via options.helpers when calling the render() and renderView() methods.

The following example shows helpers being specified at each level:

app.js:

Creates a super simple Express app which shows the basic way to register ExpressHandlebars instance-level helpers, and override one at the render-level.

var express = require('express'),
    exphbs  = require('express3-handlebars'),

    app = express(),
    hbs;

hbs = exphbs.create({
    // Specify helpers which are only registered on this instance.
    helpers: {
        foo: function () { return 'FOO!'; },
        bar: function () { return 'BAR!'; }
    }
});

app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');

app.get('/', function (req, res, next) {
    res.render('home', {
        showTitle: true,

        // Override `foo` helper only for this rendering.
        helpers: {
            foo: function () { return 'foo.'; }
        }
    });
});

app.listen(3000);

views/home.handlebars:

The app's home view which uses helper functions to help render the contents.

<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Example App - Home</title>
</head>
<body>

    <!-- Uses built-in `if` helper. -->
  {{#if showTitle}}
    <h1>Home</h1>
  {{/if}}

    <!-- Calls `foo` helper, overridden at render-level. -->
    <p>{{foo}}</p>

    <!-- Calls `bar` helper, defined at instance-level. -->
    <p>{{bar}}</p>

</body>
</html>

More on Helpers

Refer to the Handlebars website for more information on defining helpers:

API

Configuration and Defaults

There are two main ways to use this package: via its engine factory function, or creating ExpressHandlebars instances; both use the same configuration properties and defaults.

var exphbs = require('express3-handlebars');

// Using the engine factory:
exphbs({ /* config */ });

// Create an instance:
exphbs.create({ /* config */ });

The following is the list of configuration properties and their default values (if any):

defaultLayout

The string name or path of a template in the layoutsDir to use as the default layout. This is overridden by a layout specified in the app or response locals. Note: A falsy value will render without a layout; e.g., res.render('home', {layout: false});.

extname=".handlebars"

The string name of the file extension used by the templates. This value should correspond with the extname under which this view engine is registered with Express when calling app.engine().

The following example sets up an Express app to use .hbs as the file extension for views:

var express = require('express'),
    exphbs  = require('express3-handlebars'),

    app = express();

app.engine('.hbs', exphbs({extname: '.hbs'}));
app.set('view engine', '.hbs');

Note: Setting the app's "view engine" setting will make that value the default file extension used for looking up views.

handlebars=require('handlebars')

The Handlebars module/implementation. This allows for the ExpressHandlebars instance to use a different Handlebars module/implementation than that provided by the Handlebars npm package.

helpers

An object which holds the helper functions used when rendering templates with this ExpressHandlebars instance. When rendering a template, a collection of helpers will be generated by merging: handlebars.helpers (global), helpers (instance), and options.helpers (render-level). This allows Handlebars' registerHelper() function to operate as expected, will providing two extra levels over helper overrides.

layoutsDir="views/layouts/"

The string path to the directory where the layout templates reside.

partialsDir="views/partials/"

The string path to the directory where the partials templates reside.

Properties

The public API properties are provided via ExpressHandlebars instances. In additional to the properties listed in the Configuration and Defaults section, the following are additional public properties:

compiled

An object cache which holds compiled Handlebars template functions in the format: {"path/to/template": [Function]}.

engine

A function reference to the renderView() method which is bound to this ExpressHandlebars instance. This bound function should be used when registering this view engine with an Express app.

handlebarsVersion

The version number of handlebars as a semver. This is unsed internally to branch on certain operations which differ between Handlebars releases.

precompiled

An object cache which holds precompiled Handlebars template strings in the format: {"path/to/template": [String]}.

Methods

The following is the list of public API methods provided via ExpressHandlebars instances:

loadPartials(options|callback, [callback])

Retrieves the partials in the partialsDir and passes an object mapping the partials in the form {name: partial} to the callback.

By default each partial will be a compiled Handlebars template function. Use options.precompiled to receive the partials as precompiled templates — this is useful for sharing templates with client code.

Parameters:

  • [options]: Optional object containing any of the following properties:

    • [cache]: Whether cached templates can be used if they have already been requested. This is recommended for production to avoid unnecessary file I/O.

    • [precompiled=false]: Whether precompiled templates should be provided, instead of compiled Handlebars template functions.

  • callback: Function to call once the partials are retrieved.

The name of each partial corresponds to its location in partialsDir. For example, consider the following directory structure:

views
└── partials
    ├── foo
    │   └── bar.handlebars
    └── title.handlebars

2 directories, 2 files

loadPartials() would produce the following result:

var hbs = require('express3-handlebars').create();

hbs.loadPartials(function (err, partials) {
    console.log(partials);
    // => { 'foo.bar': [Function],
    // =>    title: [Function] }
});

Note: The partial name "foo.bar" would ideally be "foo/bar", but this is being prevented by a Handlebars bug. Once this bug is fixed, a future version will use a "/" separator. Templates requiring the partial still use: {{> foo/bar}}.

loadTemplate(filePath, options|callback, [callback])

Retrieves the template at the specified filePath and passes a compiled Handlebars template function to the callback.

Use options.precompiled to receive a precompiled Handlebars template.

Parameters:

  • filePath: String path to the Handlebars template file.

  • [options]: Optional object containing any of the following properties:

    • [cache]: Whether a cached template can be used if it have already been requested. This is recommended for production to avoid necessary file I/O.

    • [precompiled=false]: Whether a precompiled template should be provided, instead of a compiled Handlebars template function.

  • callback: Function to call once the template is retrieved.

loadTemplates(dirPath, options|callback, [callback])

Retrieves the all the templates in the specified dirPath and passes an object mapping the compiled templates in the form {filename: template} to the callback.

Use options.precompiled to receive precompiled Handlebars templates — this is useful for sharing templates with client code.

Parameters:

  • dirPath: String path to the directory containing Handlebars template files.

  • [options]: Optional object containing any of the following properties:

    • [cache]: Whether cached templates can be used if it have already been requested. This is recommended for production to avoid necessary file I/O.

    • [precompiled=false]: Whether precompiled templates should be provided, instead of a compiled Handlebars template function.

  • callback: Function to call once the templates are retrieved.

render(filePath, options|callback, [callback])

Renders the template at the specified filePath using this instance's helpers and partials, and passes the resulting string to the callback.

The options will be used both as the context in which the Handlebars template is rendered, and to signal this view engine on how it should behave, e.g., options.cache = false will load always load the templates from disk.

Parameters:

  • filePath: String path to the Handlebars template file.

  • [options]: Optional object which will serve as the context in which the Handlebars template is rendered. It may also contain any of the following properties which affect this view engine's behavior:

    • [cache]: Whether a cached template can be used if it have already been requested. This is recommended for production to avoid unnecessary file I/O.

    • [helpers]: Render-level helpers should be merged with (and will override) instance and global helper functions.

  • callback: Function to call once the template is retrieved.

renderView(viewPath, options|callback, [callback])

Renders the template at the specified viewPath as the {{{body}}} within the layout specified by the defaultLayout or options.layout. Rendering will use this instance's helpers and partials, and passes the resulting string to the callback.

This method is called by Express and is the main entry point into this Express view engine implementation. It adds the concept of a "layout" and delegates rendering to the render() method.

The options will be used both as the context in which the Handlebars templates are rendered, and to signal this view engine on how it should behave, e.g., options.cache=false will load always load the templates from disk.

Parameters:

  • viewPath: String path to the Handlebars template file which should serve as the {{{body}}} when using a layout.

  • [options]: Optional object which will serve as the context in which the Handlebars templates are rendered. It may also contain any of the following properties which affect this view engine's behavior:

    • [cache]: Whether cached templates can be used if they have already been requested. This is recommended for production to avoid unnecessary file I/O.

    • [helpers]: Render-level helpers should be merged with (and will override) instance and global helper functions.

    • [layout]: Optional string path to the Handlebars template file to be used as the "layout". This overrides any defaultLayout value. Passing a falsy value will render with no layout (even if a defaultLayout is defined).

  • callback: Function to call once the template is retrieved.

Statics

The following is the list of static API properties and methods provided on the ExpressHandlebars constructor:

getHandlebarsSemver(handlebars)

Returns a semver-compatible version string for the specified handlebars module/implementation.

This utility function is used to compute the value for an ExpressHandlebars instance's handlebarsVersion property.

Examples

Basic Usage

This example shows the most basic way to use this view engine.

Advanced Usage

This example is more comprehensive and shows how to use many of the features of this view engine, including helpers, partials, multiple layouts, etc.

As noted in the Package Design section, this view engine's implementation is instance-based, and more advanced usages can take advantage of this. The Advanced Usage example demonstrates how to use an ExpressHandlebars instance to share templates with the client, among other features.

License

This software is free to use under the Yahoo! Inc. BSD license. See the LICENSE file for license text and copyright information.

changelog (log de mudanças)

4.7.2 / 2014-07-27

  • deps: depd@0.4.4
    • Work-around v8 generating empty stack traces
  • deps: send@0.7.2
    • deps: depd@0.4.4
  • deps: serve-static@~1.4.2

4.7.1 / 2014-07-26

  • deps: depd@0.4.3
    • Fix exception when global Error.stackTraceLimit is too low
  • deps: send@0.7.1
    • deps: depd@0.4.3
  • deps: serve-static@~1.4.1

4.7.0 / 2014-07-25

  • fix req.protocol for proxy-direct connections
  • configurable query parser with app.set('query parser', parser)
    • app.set('query parser', 'extended') parse with "qs" module
    • app.set('query parser', 'simple') parse with "querystring" core module
    • app.set('query parser', false) disable query string parsing
    • app.set('query parser', true) enable simple parsing
  • deprecate res.json(status, obj) -- use res.status(status).json(obj) instead
  • deprecate res.jsonp(status, obj) -- use res.status(status).jsonp(obj) instead
  • deprecate res.send(status, body) -- use res.status(status).send(body) instead
  • deps: debug@1.0.4
  • deps: depd@0.4.2
    • Add TRACE_DEPRECATION environment variable
    • Remove non-standard grey color from color output
    • Support --no-deprecation argument
    • Support --trace-deprecation argument
  • deps: finalhandler@0.1.0
    • Respond after request fully read
    • deps: debug@1.0.4
  • deps: parseurl@~1.2.0
    • Cache URLs based on original value
    • Remove no-longer-needed URL mis-parse work-around
    • Simplify the "fast-path" RegExp
  • deps: send@0.7.0
    • Add dotfiles option
    • Cap maxAge value to 1 year
    • deps: debug@1.0.4
    • deps: depd@0.4.2
  • deps: serve-static@~1.4.0
    • deps: parseurl@~1.2.0
    • deps: send@0.7.0
  • perf: prevent multiple Buffer creation in res.send

4.6.1 / 2014-07-12

  • fix subapp.mountpath regression for app.use(subapp)

4.6.0 / 2014-07-11

  • accept multiple callbacks to app.use()
  • add explicit "Rosetta Flash JSONP abuse" protection
    • previous versions are not vulnerable; this is just explicit protection
  • catch errors in multiple req.param(name, fn) handlers
  • deprecate res.redirect(url, status) -- use res.redirect(status, url) instead
  • fix res.send(status, num) to send num as json (not error)
  • remove unnecessary escaping when res.jsonp returns JSON response
  • support non-string path in app.use(path, fn)
    • supports array of paths
    • supports RegExp
  • router: fix optimization on router exit
  • router: refactor location of try blocks
  • router: speed up standard app.use(fn)
  • deps: debug@1.0.3
    • Add support for multiple wildcards in namespaces
  • deps: finalhandler@0.0.3
    • deps: debug@1.0.3
  • deps: methods@1.1.0
    • add CONNECT
  • deps: parseurl@~1.1.3
    • faster parsing of href-only URLs
  • deps: path-to-regexp@0.1.3
  • deps: send@0.6.0
    • deps: debug@1.0.3
  • deps: serve-static@~1.3.2
    • deps: parseurl@~1.1.3
    • deps: send@0.6.0
  • perf: fix arguments reassign deopt in some res methods

4.5.1 / 2014-07-06

  • fix routing regression when altering req.method

4.5.0 / 2014-07-04

  • add deprecation message to non-plural req.accepts*
  • add deprecation message to res.send(body, status)
  • add deprecation message to res.vary()
  • add headers option to res.sendfile
    • use to set headers on successful file transfer
  • add mergeParams option to Router
    • merges req.params from parent routes
  • add req.hostname -- correct name for what req.host returns
  • deprecate things with depd module
  • deprecate req.host -- use req.hostname instead
  • fix behavior when handling request without routes
  • fix handling when route.all is only route
  • invoke router.param() only when route matches
  • restore req.params after invoking router
  • use finalhandler for final response handling
  • use media-typer to alter content-type charset
  • deps: accepts@~1.0.7
  • deps: send@0.5.0
    • Accept string for maxage (converted by ms)
    • Include link in default redirect response
  • deps: serve-static@~1.3.0
    • Accept string for maxAge (converted by ms)
    • Add setHeaders option
    • Include HTML link in redirect response
    • deps: send@0.5.0
  • deps: type-is@~1.3.2

4.4.5 / 2014-06-26

  • deps: cookie-signature@1.0.4
    • fix for timing attacks

4.4.4 / 2014-06-20

  • fix res.attachment Unicode filenames in Safari
  • fix "trim prefix" debug message in express:router
  • deps: accepts@~1.0.5
  • deps: buffer-crc32@0.2.3

4.4.3 / 2014-06-11

  • fix persistence of modified req.params[name] from app.param()
  • deps: accepts@1.0.3
    • deps: negotiator@0.4.6
  • deps: debug@1.0.2
  • deps: send@0.4.3
    • Do not throw un-catchable error on file open race condition
    • Use escape-html for HTML escaping
    • deps: debug@1.0.2
    • deps: finished@1.2.2
    • deps: fresh@0.2.2
  • deps: serve-static@1.2.3
    • Do not throw un-catchable error on file open race condition
    • deps: send@0.4.3

4.4.2 / 2014-06-09

  • fix catching errors from top-level handlers
  • use vary module for res.vary
  • deps: debug@1.0.1
  • deps: proxy-addr@1.0.1
  • deps: send@0.4.2
    • fix "event emitter leak" warnings
    • deps: debug@1.0.1
    • deps: finished@1.2.1
  • deps: serve-static@1.2.2
    • fix "event emitter leak" warnings
    • deps: send@0.4.2
  • deps: type-is@1.2.1

4.4.1 / 2014-06-02

  • deps: methods@1.0.1
  • deps: send@0.4.1
    • Send max-age in Cache-Control in correct format
  • deps: serve-static@1.2.1
    • use escape-html for escaping
    • deps: send@0.4.1

4.4.0 / 2014-05-30

  • custom etag control with app.set('etag', val)
    • app.set('etag', function(body, encoding){ return '"etag"' }) custom etag generation
    • app.set('etag', 'weak') weak tag
    • app.set('etag', 'strong') strong etag
    • app.set('etag', false) turn off
    • app.set('etag', true) standard etag
  • mark res.send ETag as weak and reduce collisions
  • update accepts to 1.0.2
    • Fix interpretation when header not in request
  • update send to 0.4.0
    • Calculate ETag with md5 for reduced collisions
    • Ignore stream errors after request ends
    • deps: debug@0.8.1
  • update serve-static to 1.2.0
    • Calculate ETag with md5 for reduced collisions
    • Ignore stream errors after request ends
    • deps: send@0.4.0

4.3.2 / 2014-05-28

  • fix handling of errors from router.param() callbacks

4.3.1 / 2014-05-23

  • revert "fix behavior of multiple app.VERB for the same path"
    • this caused a regression in the order of route execution

4.3.0 / 2014-05-21

  • add req.baseUrl to access the path stripped from req.url in routes
  • fix behavior of multiple app.VERB for the same path
  • fix issue routing requests among sub routers
  • invoke router.param() only when necessary instead of every match
  • proper proxy trust with app.set('trust proxy', trust)
    • app.set('trust proxy', 1) trust first hop
    • app.set('trust proxy', 'loopback') trust loopback addresses
    • app.set('trust proxy', '10.0.0.1') trust single IP
    • app.set('trust proxy', '10.0.0.1/16') trust subnet
    • app.set('trust proxy', '10.0.0.1, 10.0.0.2') trust list
    • app.set('trust proxy', false) turn off
    • app.set('trust proxy', true) trust everything
  • set proper charset in Content-Type for res.send
  • update type-is to 1.2.0
    • support suffix matching

4.2.0 / 2014-05-11

  • deprecate app.del() -- use app.delete() instead
  • deprecate res.json(obj, status) -- use res.json(status, obj) instead
    • the edge-case res.json(status, num) requires res.status(status).json(num)
  • deprecate res.jsonp(obj, status) -- use res.jsonp(status, obj) instead
    • the edge-case res.jsonp(status, num) requires res.status(status).jsonp(num)
  • fix req.next when inside router instance
  • include ETag header in HEAD requests
  • keep previous Content-Type for res.jsonp
  • support PURGE method
    • add app.purge
    • add router.purge
    • include PURGE in app.all
  • update debug to 0.8.0
    • add enable() method
    • change from stderr to stdout
  • update methods to 1.0.0
    • add PURGE

4.1.2 / 2014-05-08

  • fix req.host for IPv6 literals
  • fix res.jsonp error if callback param is object

4.1.1 / 2014-04-27

  • fix package.json to reflect supported node version

4.1.0 / 2014-04-24

  • pass options from res.sendfile to send
  • preserve casing of headers in res.header and res.set
  • support unicode file names in res.attachment and res.download
  • update accepts to 1.0.1
    • deps: negotiator@0.4.0
  • update cookie to 0.1.2
    • Fix for maxAge == 0
    • made compat with expires field
  • update send to 0.3.0
    • Accept API options in options object
    • Coerce option types
    • Control whether to generate etags
    • Default directory access to 403 when index disabled
    • Fix sending files with dots without root set
    • Include file path in etag
    • Make "Can't set headers after they are sent." catchable
    • Send full entity-body for multi range requests
    • Set etags to "weak"
    • Support "If-Range" header
    • Support multiple index paths
    • deps: mime@1.2.11
  • update serve-static to 1.1.0
    • Accept options directly to send module
    • Resolve relative paths at middleware setup
    • Use parseurl to parse the URL from request
    • deps: send@0.3.0
  • update type-is to 1.1.0
    • add non-array values support
    • add multipart as a shorthand

4.0.0 / 2014-04-09

  • remove:
    • node 0.8 support
    • connect and connect's patches except for charset handling
    • express(1) - moved to express-generator
    • express.createServer() - it has been deprecated for a long time. Use express()
    • app.configure - use logic in your own app code
    • app.router - is removed
    • req.auth - use basic-auth instead
    • req.accepted* - use req.accepts*() instead
    • res.location - relative URL resolution is removed
    • res.charset - include the charset in the content type when using res.set()
    • all bundled middleware except static
  • change:
    • app.route -> app.mountpath when mounting an express app in another express app
    • json spaces no longer enabled by default in development
    • req.accepts* -> req.accepts*s - i.e. req.acceptsEncoding -> req.acceptsEncodings
    • req.params is now an object instead of an array
    • res.locals is no longer a function. It is a plain js object. Treat it as such.
    • res.headerSent -> res.headersSent to match node.js ServerResponse object
  • refactor:
  • add:
    • app.router() - returns the app Router instance
    • app.route() - Proxy to the app's Router#route() method to create a new route
    • Router & Route - public API

3.15.2 / 2014-07-27

  • deps: connect@2.24.2
    • deps: body-parser@~1.5.2
    • deps: depd@0.4.4
    • deps: express-session@~1.7.2
    • deps: morgan@~1.2.2
    • deps: serve-static@~1.4.2
  • deps: depd@0.4.4
    • Work-around v8 generating empty stack traces
  • deps: send@0.7.2
    • deps: depd@0.4.4

3.15.1 / 2014-07-26

  • deps: connect@2.24.1
    • deps: body-parser@~1.5.1
    • deps: depd@0.4.3
    • deps: express-session@~1.7.1
    • deps: morgan@~1.2.1
    • deps: serve-index@~1.1.4
    • deps: serve-static@~1.4.1
  • deps: depd@0.4.3
    • Fix exception when global Error.stackTraceLimit is too low
  • deps: send@0.7.1
    • deps: depd@0.4.3

3.15.0 / 2014-07-22

  • Fix req.protocol for proxy-direct connections
  • Pass options from res.sendfile to send
  • deps: connect@2.24.0
    • deps: body-parser@~1.5.0
    • deps: compression@~1.0.9
    • deps: connect-timeout@~1.2.1
    • deps: debug@1.0.4
    • deps: depd@0.4.2
    • deps: express-session@~1.7.0
    • deps: finalhandler@0.1.0
    • deps: method-override@~2.1.2
    • deps: morgan@~1.2.0
    • deps: multiparty@3.3.1
    • deps: parseurl@~1.2.0
    • deps: serve-static@~1.4.0
  • deps: debug@1.0.4
  • deps: depd@0.4.2
    • Add TRACE_DEPRECATION environment variable
    • Remove non-standard grey color from color output
    • Support --no-deprecation argument
    • Support --trace-deprecation argument
  • deps: parseurl@~1.2.0
    • Cache URLs based on original value
    • Remove no-longer-needed URL mis-parse work-around
    • Simplify the "fast-path" RegExp
  • deps: send@0.7.0
    • Add dotfiles option
    • Cap maxAge value to 1 year
    • deps: debug@1.0.4
    • deps: depd@0.4.2

3.14.0 / 2014-07-11

  • add explicit "Rosetta Flash JSONP abuse" protection
    • previous versions are not vulnerable; this is just explicit protection
  • deprecate res.redirect(url, status) -- use res.redirect(status, url) instead
  • fix res.send(status, num) to send num as json (not error)
  • remove unnecessary escaping when res.jsonp returns JSON response
  • deps: basic-auth@1.0.0
    • support empty password
    • support empty username
  • deps: connect@2.23.0
    • deps: debug@1.0.3
    • deps: express-session@~1.6.4
    • deps: method-override@~2.1.0
    • deps: parseurl@~1.1.3
    • deps: serve-static@~1.3.1
    • deps: debug@1.0.3
      • Add support for multiple wildcards in namespaces
    • deps: methods@1.1.0
      • add CONNECT
    • deps: parseurl@~1.1.3
      • faster parsing of href-only URLs

3.13.0 / 2014-07-03

  • add deprecation message to app.configure
  • add deprecation message to req.auth
  • use basic-auth to parse Authorization header
  • deps: connect@2.22.0
    • deps: csurf@~1.3.0
    • deps: express-session@~1.6.1
    • deps: multiparty@3.3.0
    • deps: serve-static@~1.3.0
  • deps: send@0.5.0
    • Accept string for maxage (converted by ms)
    • Include link in default redirect response

3.12.1 / 2014-06-26

  • deps: connect@2.21.1
    • deps: cookie-parser@1.3.2
    • deps: cookie-signature@1.0.4
    • deps: express-session@~1.5.2
    • deps: type-is@~1.3.2
  • deps: cookie-signature@1.0.4
    • fix for timing attacks

3.12.0 / 2014-06-21

  • use media-typer to alter content-type charset
  • deps: connect@2.21.0
    • deprecate connect(middleware) -- use app.use(middleware) instead
    • deprecate connect.createServer() -- use connect() instead
    • fix res.setHeader() patch to work with with get -> append -> set pattern
    • deps: compression@~1.0.8
    • deps: errorhandler@~1.1.1
    • deps: express-session@~1.5.0
    • deps: serve-index@~1.1.3

3.11.0 / 2014-06-19

  • deprecate things with depd module
  • deps: buffer-crc32@0.2.3
  • deps: connect@2.20.2
    • deprecate verify option to json -- use body-parser npm module instead
    • deprecate verify option to urlencoded -- use body-parser npm module instead
    • deprecate things with depd module
    • use finalhandler for final response handling
    • use media-typer to parse content-type for charset
    • deps: body-parser@1.4.3
    • deps: connect-timeout@1.1.1
    • deps: cookie-parser@1.3.1
    • deps: csurf@1.2.2
    • deps: errorhandler@1.1.0
    • deps: express-session@1.4.0
    • deps: multiparty@3.2.9
    • deps: serve-index@1.1.2
    • deps: type-is@1.3.1
    • deps: vhost@2.0.0

3.10.5 / 2014-06-11

  • deps: connect@2.19.6
    • deps: body-parser@1.3.1
    • deps: compression@1.0.7
    • deps: debug@1.0.2
    • deps: serve-index@1.1.1
    • deps: serve-static@1.2.3
  • deps: debug@1.0.2
  • deps: send@0.4.3
    • Do not throw un-catchable error on file open race condition
    • Use escape-html for HTML escaping
    • deps: debug@1.0.2
    • deps: finished@1.2.2
    • deps: fresh@0.2.2

3.10.4 / 2014-06-09

  • deps: connect@2.19.5
    • fix "event emitter leak" warnings
    • deps: csurf@1.2.1
    • deps: debug@1.0.1
    • deps: serve-static@1.2.2
    • deps: type-is@1.2.1
  • deps: debug@1.0.1
  • deps: send@0.4.2
    • fix "event emitter leak" warnings
    • deps: finished@1.2.1
    • deps: debug@1.0.1

3.10.3 / 2014-06-05

  • use vary module for res.vary
  • deps: connect@2.19.4
    • deps: errorhandler@1.0.2
    • deps: method-override@2.0.2
    • deps: serve-favicon@2.0.1
  • deps: debug@1.0.0

3.10.2 / 2014-06-03

  • deps: connect@2.19.3
    • deps: compression@1.0.6

3.10.1 / 2014-06-03

  • deps: connect@2.19.2
    • deps: compression@1.0.4
  • deps: proxy-addr@1.0.1

3.10.0 / 2014-06-02

  • deps: connect@2.19.1
    • deprecate methodOverride() -- use method-override npm module instead
    • deps: body-parser@1.3.0
    • deps: method-override@2.0.1
    • deps: multiparty@3.2.8
    • deps: response-time@2.0.0
    • deps: serve-static@1.2.1
  • deps: methods@1.0.1
  • deps: send@0.4.1
    • Send max-age in Cache-Control in correct format

3.9.0 / 2014-05-30

  • custom etag control with app.set('etag', val)
    • app.set('etag', function(body, encoding){ return '"etag"' }) custom etag generation
    • app.set('etag', 'weak') weak tag
    • app.set('etag', 'strong') strong etag
    • app.set('etag', false) turn off
    • app.set('etag', true) standard etag
  • Include ETag in HEAD requests
  • mark res.send ETag as weak and reduce collisions
  • update connect to 2.18.0
    • deps: compression@1.0.3
    • deps: serve-index@1.1.0
    • deps: serve-static@1.2.0
  • update send to 0.4.0
    • Calculate ETag with md5 for reduced collisions
    • Ignore stream errors after request ends
    • deps: debug@0.8.1

3.8.1 / 2014-05-27

  • update connect to 2.17.3
    • deps: body-parser@1.2.2
    • deps: express-session@1.2.1
    • deps: method-override@1.0.2

3.8.0 / 2014-05-21

  • keep previous Content-Type for res.jsonp
  • set proper charset in Content-Type for res.send
  • update connect to 2.17.1
    • fix res.charset appending charset when content-type has one
    • deps: express-session@1.2.0
    • deps: morgan@1.1.1
    • deps: serve-index@1.0.3

3.7.0 / 2014-05-18

  • proper proxy trust with app.set('trust proxy', trust)
    • app.set('trust proxy', 1) trust first hop
    • app.set('trust proxy', 'loopback') trust loopback addresses
    • app.set('trust proxy', '10.0.0.1') trust single IP
    • app.set('trust proxy', '10.0.0.1/16') trust subnet
    • app.set('trust proxy', '10.0.0.1, 10.0.0.2') trust list
    • app.set('trust proxy', false) turn off
    • app.set('trust proxy', true) trust everything
  • update connect to 2.16.2
    • deprecate res.headerSent -- use res.headersSent
    • deprecate res.on("header") -- use on-headers module instead
    • fix edge-case in res.appendHeader that would append in wrong order
    • json: use body-parser
    • urlencoded: use body-parser
    • dep: bytes@1.0.0
    • dep: cookie-parser@1.1.0
    • dep: csurf@1.2.0
    • dep: express-session@1.1.0
    • dep: method-override@1.0.1

3.6.0 / 2014-05-09

  • deprecate app.del() -- use app.delete() instead
  • deprecate res.json(obj, status) -- use res.json(status, obj) instead
    • the edge-case res.json(status, num) requires res.status(status).json(num)
  • deprecate res.jsonp(obj, status) -- use res.jsonp(status, obj) instead
    • the edge-case res.jsonp(status, num) requires res.status(status).jsonp(num)
  • support PURGE method
    • add app.purge
    • add router.purge
    • include PURGE in app.all
  • update connect to 2.15.0
    • Add res.appendHeader
    • Call error stack even when response has been sent
    • Patch res.headerSent to return Boolean
    • Patch res.headersSent for node.js 0.8
    • Prevent default 404 handler after response sent
    • dep: compression@1.0.2
    • dep: connect-timeout@1.1.0
    • dep: debug@^0.8.0
    • dep: errorhandler@1.0.1
    • dep: express-session@1.0.4
    • dep: morgan@1.0.1
    • dep: serve-favicon@2.0.0
    • dep: serve-index@1.0.2
  • update debug to 0.8.0
    • add enable() method
    • change from stderr to stdout
  • update methods to 1.0.0
    • add PURGE
  • update mkdirp to 0.5.0

3.5.3 / 2014-05-08

  • fix req.host for IPv6 literals
  • fix res.jsonp error if callback param is object

3.5.2 / 2014-04-24

  • update connect to 2.14.5
  • update cookie to 0.1.2
  • update mkdirp to 0.4.0
  • update send to 0.3.0

3.5.1 / 2014-03-25

  • pin less-middleware in generated app

3.5.0 / 2014-03-06

  • bump deps

3.4.8 / 2014-01-13

  • prevent incorrect automatic OPTIONS responses #1868 @dpatti
  • update binary and examples for jade 1.0 #1876 @yossi, #1877 @reqshark, #1892 @matheusazzi
  • throw 400 in case of malformed paths @rlidwka

3.4.7 / 2013-12-10

  • update connect

3.4.6 / 2013-12-01

  • update connect (raw-body)

3.4.5 / 2013-11-27

  • update connect
  • res.location: remove leading ./ #1802 @kapouer
  • res.redirect: fix `res.redirect('toString') #1829 @michaelficarra
  • res.send: always send ETag when content-length > 0
  • router: add Router.all() method

3.4.4 / 2013-10-29

  • update connect
  • update supertest
  • update methods
  • express(1): replace bodyParser() with urlencoded() and json() #1795 @chirag04

3.4.3 / 2013-10-23

  • update connect

3.4.2 / 2013-10-18

  • update connect
  • downgrade commander

3.4.1 / 2013-10-15

  • update connect
  • update commander
  • jsonp: check if callback is a function
  • router: wrap encodeURIComponent in a try/catch #1735 (@lxe)
  • res.format: now includes chraset @1747 (@sorribas)
  • res.links: allow multiple calls @1746 (@sorribas)

3.4.0 / 2013-09-07

  • add res.vary(). Closes #1682
  • update connect

3.3.8 / 2013-09-02

  • update connect

3.3.7 / 2013-08-28

  • update connect

3.3.6 / 2013-08-27

  • Revert "remove charset from json responses. Closes #1631" (causes issues in some clients)
  • add: req.accepts take an argument list

3.3.4 / 2013-07-08

  • update send and connect

3.3.3 / 2013-07-04

  • update connect

3.3.2 / 2013-07-03

  • update connect
  • update send
  • remove .version export

3.3.1 / 2013-06-27

  • update connect

3.3.0 / 2013-06-26

  • update connect
  • add support for multiple X-Forwarded-Proto values. Closes #1646
  • change: remove charset from json responses. Closes #1631
  • change: return actual booleans from req.accept* functions
  • fix jsonp callback array throw

3.2.6 / 2013-06-02

  • update connect

3.2.5 / 2013-05-21

  • update connect
  • update node-cookie
  • add: throw a meaningful error when there is no default engine
  • change generation of ETags with res.send() to GET requests only. Closes #1619

3.2.4 / 2013-05-09

  • fix req.subdomains when no Host is present
  • fix req.host when no Host is present, return undefined

3.2.3 / 2013-05-07

  • update connect / qs

3.2.2 / 2013-05-03

  • update qs

3.2.1 / 2013-04-29

  • add app.VERB() paths array deprecation warning
  • update connect
  • update qs and remove all ~ semver crap
  • fix: accept number as value of Signed Cookie

3.2.0 / 2013-04-15

  • add "view" constructor setting to override view behaviour
  • add req.acceptsEncoding(name)
  • add req.acceptedEncodings
  • revert cookie signature change causing session race conditions
  • fix sorting of Accept values of the same quality

3.1.2 / 2013-04-12

  • add support for custom Accept parameters
  • update cookie-signature

3.1.1 / 2013-04-01

  • add X-Forwarded-Host support to req.host
  • fix relative redirects
  • update mkdirp
  • update buffer-crc32
  • remove legacy app.configure() method from app template.

3.1.0 / 2013-01-25

  • add support for leading "." in "view engine" setting
  • add array support to res.set()
  • add node 0.8.x to travis.yml
  • add "subdomain offset" setting for tweaking req.subdomains
  • add res.location(url) implementing res.redirect()-like setting of Location
  • use app.get() for x-powered-by setting for inheritance
  • fix colons in passwords for req.auth

3.0.6 / 2013-01-04

  • add http verb methods to Router
  • update connect
  • fix mangling of the res.cookie() options object
  • fix jsonp whitespace escape. Closes #1132

3.0.5 / 2012-12-19

  • add throwing when a non-function is passed to a route
  • fix: explicitly remove Transfer-Encoding header from 204 and 304 responses
  • revert "add 'etag' option"

3.0.4 / 2012-12-05

  • add 'etag' option to disable res.send() Etags
  • add escaping of urls in text/plain in res.redirect() for old browsers interpreting as html
  • change crc32 module for a more liberal license
  • update connect

3.0.3 / 2012-11-13

  • update connect
  • update cookie module
  • fix cookie max-age

3.0.2 / 2012-11-08

  • add OPTIONS to cors example. Closes #1398
  • fix route chaining regression. Closes #1397

3.0.1 / 2012-11-01

  • update connect

3.0.0 / 2012-10-23

  • add make clean
  • add "Basic" check to req.auth
  • add req.auth test coverage
  • add cb && cb(payload) to res.jsonp(). Closes #1374
  • add backwards compat for res.redirect() status. Closes #1336
  • add support for res.json() to retain previously defined Content-Types. Closes #1349
  • update connect
  • change res.redirect() to utilize a pathname-relative Location again. Closes #1382
  • remove non-primitive string support for res.send()
  • fix view-locals example. Closes #1370
  • fix route-separation example

3.0.0rc5 / 2012-09-18

  • update connect
  • add redis search example
  • add static-files example
  • add "x-powered-by" setting (app.disable('x-powered-by'))
  • add "application/octet-stream" redirect Accept test case. Closes #1317

3.0.0rc4 / 2012-08-30

  • add res.jsonp(). Closes #1307
  • add "verbose errors" option to error-pages example
  • add another route example to express(1) so people are not so confused
  • add redis online user activity tracking example
  • update connect dep
  • fix etag quoting. Closes #1310
  • fix error-pages 404 status
  • fix jsonp callback char restrictions
  • remove old OPTIONS default response

3.0.0rc3 / 2012-08-13

  • update connect dep
  • fix signed cookies to work with connect.cookieParser() ("s:" prefix was missing) [tnydwrds]
  • fix res.render() clobbering of "locals"

3.0.0rc2 / 2012-08-03

  • add CORS example
  • update connect dep
  • deprecate .createServer() & remove old stale examples
  • fix: escape res.redirect() link
  • fix vhost example

3.0.0rc1 / 2012-07-24

  • add more examples to view-locals
  • add scheme-relative redirects (res.redirect("//foo.com")) support
  • update cookie dep
  • update connect dep
  • update send dep
  • fix express(1) -h flag, use -H for hogan. Closes #1245
  • fix res.sendfile() socket error handling regression

3.0.0beta7 / 2012-07-16

  • update connect dep for send() root normalization regression

3.0.0beta6 / 2012-07-13

  • add err.view property for view errors. Closes #1226
  • add "jsonp callback name" setting
  • add support for "/foo/:bar*" non-greedy matches
  • change res.sendfile() to use send() module
  • change res.send to use "response-send" module
  • remove app.locals.use and res.locals.use, use regular middleware

3.0.0beta5 / 2012-07-03

  • add "make check" support
  • add route-map example
  • add res.json(obj, status) support back for BC
  • add "methods" dep, remove internal methods module
  • update connect dep
  • update auth example to utilize cores pbkdf2
  • updated tests to use "supertest"

3.0.0beta4 / 2012-06-25

  • Added req.auth
  • Added req.range(size)
  • Added res.links(obj)
  • Added res.send(body, status) support back for backwards compat
  • Added .default() support to res.format()
  • Added 2xx / 304 check to req.fresh
  • Revert "Added + support to the router"
  • Fixed res.send() freshness check, respect res.statusCode

3.0.0beta3 / 2012-06-15

  • Added hogan --hjs to express(1) [nullfirm]
  • Added another example to content-negotiation
  • Added fresh dep
  • Changed: res.send() always checks freshness
  • Fixed: expose connects mime module. Cloases #1165

3.0.0beta2 / 2012-06-06

  • Added + support to the router
  • Added req.host
  • Changed req.param() to check route first
  • Update connect dep

3.0.0beta1 / 2012-06-01

  • Added res.format() callback to override default 406 behaviour
  • Fixed res.redirect() 406. Closes #1154

3.0.0alpha5 / 2012-05-30

  • Added req.ip
  • Added { signed: true } option to res.cookie()
  • Removed res.signedCookie()
  • Changed: dont reverse req.ips
  • Fixed "trust proxy" setting check for req.ips

3.0.0alpha4 / 2012-05-09

  • Added: allow [] in jsonp callback. Closes #1128
  • Added PORT env var support in generated template. Closes #1118 [benatkin]
  • Updated: connect 2.2.2

3.0.0alpha3 / 2012-05-04

  • Added public app.routes. Closes #887
  • Added view-locals example
  • Added mvc example
  • Added res.locals.use(). Closes #1120
  • Added conditional-GET support to res.send()
  • Added: coerce res.set() values to strings
  • Changed: moved static() in generated apps below router
  • Changed: res.send() only set ETag when not previously set
  • Changed connect 2.2.1 dep
  • Changed: make test now runs unit / acceptance tests
  • Fixed req/res proto inheritance

3.0.0alpha2 / 2012-04-26

  • Added make benchmark back
  • Added res.send() support for String objects
  • Added client-side data exposing example
  • Added res.header() and req.header() aliases for BC
  • Added express.createServer() for BC
  • Perf: memoize parsed urls
  • Perf: connect 2.2.0 dep
  • Changed: make expressInit() middleware self-aware
  • Fixed: use app.get() for all core settings
  • Fixed redis session example
  • Fixed session example. Closes #1105
  • Fixed generated express dep. Closes #1078

3.0.0alpha1 / 2012-04-15

  • Added app.locals.use(callback)
  • Added app.locals object
  • Added app.locals(obj)
  • Added res.locals object
  • Added res.locals(obj)
  • Added res.format() for content-negotiation
  • Added app.engine()
  • Added res.cookie() JSON cookie support
  • Added "trust proxy" setting
  • Added req.subdomains
  • Added req.protocol
  • Added req.secure
  • Added req.path
  • Added req.ips
  • Added req.fresh
  • Added req.stale
  • Added comma-delmited / array support for req.accepts()
  • Added debug instrumentation
  • Added res.set(obj)
  • Added res.set(field, value)
  • Added res.get(field)
  • Added app.get(setting). Closes #842
  • Added req.acceptsLanguage()
  • Added req.acceptsCharset()
  • Added req.accepted
  • Added req.acceptedLanguages
  • Added req.acceptedCharsets
  • Added "json replacer" setting
  • Added "json spaces" setting
  • Added X-Forwarded-Proto support to res.redirect(). Closes #92
  • Added --less support to express(1)
  • Added express.response prototype
  • Added express.request prototype
  • Added express.application prototype
  • Added app.path()
  • Added app.render()
  • Added res.type() to replace res.contentType()
  • Changed: res.redirect() to add relative support
  • Changed: enable "jsonp callback" by default
  • Changed: renamed "case sensitive routes" to "case sensitive routing"
  • Rewrite of all tests with mocha
  • Removed "root" setting
  • Removed res.redirect('home') support
  • Removed req.notify()
  • Removed app.register()
  • Removed app.redirect()
  • Removed app.is()
  • Removed app.helpers()
  • Removed app.dynamicHelpers()
  • Fixed res.sendfile() with non-GET. Closes #723
  • Fixed express(1) public dir for windows. Closes #866

2.5.9/ 2012-04-02

  • Added support for PURGE request method [pbuyle]
  • Fixed express(1) generated app app.address() before listening [mmalecki]

2.5.8 / 2012-02-08

  • Update mkdirp dep. Closes #991

2.5.7 / 2012-02-06

  • Fixed app.all duplicate DELETE requests [mscdex]

2.5.6 / 2012-01-13

  • Updated hamljs dev dep. Closes #953

2.5.5 / 2012-01-08

  • Fixed: set filename on cached templates [matthewleon]

2.5.4 / 2012-01-02

  • Fixed express(1) eol on 0.4.x. Closes #947

2.5.3 / 2011-12-30

  • Fixed req.is() when a charset is present

2.5.2 / 2011-12-10

  • Fixed: express(1) LF -> CRLF for windows

2.5.1 / 2011-11-17

  • Changed: updated connect to 1.8.x
  • Removed sass.js support from express(1)

2.5.0 / 2011-10-24

  • Added ./routes dir for generated app by default
  • Added npm install reminder to express(1) app gen
  • Added 0.5.x support
  • Removed make test-cov since it wont work with node 0.5.x
  • Fixed express(1) public dir for windows. Closes #866

2.4.7 / 2011-10-05

  • Added mkdirp to express(1). Closes #795
  • Added simple json-config example
  • Added shorthand for the parsed request's pathname via req.path
  • Changed connect dep to 1.7.x to fix npm issue...
  • Fixed res.redirect() HEAD support. [reported by xerox]
  • Fixed req.flash(), only escape args
  • Fixed absolute path checking on windows. Closes #829 [reported by andrewpmckenzie]

2.4.6 / 2011-08-22

  • Fixed multiple param callback regression. Closes #824 [reported by TroyGoode]

2.4.5 / 2011-08-19

  • Added support for routes to handle errors. Closes #809
  • Added app.routes.all(). Closes #803
  • Added "basepath" setting to work in conjunction with reverse proxies etc.
  • Refactored Route to use a single array of callbacks
  • Added support for multiple callbacks for app.param(). Closes #801 Closes #805
  • Changed: removed .call(self) for route callbacks
  • Dependency: qs >= 0.3.1
  • Fixed res.redirect() on windows due to join() usage. Closes #808

2.4.4 / 2011-08-05

  • Fixed res.header() intention of a set, even when undefined
  • Fixed *, value no longer required
  • Fixed res.send(204) support. Closes #771

2.4.3 / 2011-07-14

  • Added docs for status option special-case. Closes #739
  • Fixed options.filename, exposing the view path to template engines

2.4.2. / 2011-07-06

  • Revert "removed jsonp stripping" for XSS

2.4.1 / 2011-07-06

  • Added res.json() JSONP support. Closes #737
  • Added extending-templates example. Closes #730
  • Added "strict routing" setting for trailing slashes
  • Added support for multiple envs in app.configure() calls. Closes #735
  • Changed: res.send() using res.json()
  • Changed: when cookie path === null don't default it
  • Changed; default cookie path to "home" setting. Closes #731
  • Removed pids/logs creation from express(1)

2.4.0 / 2011-06-28

  • Added chainable res.status(code)
  • Added res.json(), an explicit version of res.send(obj)
  • Added simple web-service example

2.3.12 / 2011-06-22

  • #express is now on freenode! come join!
  • Added req.get(field, param)
  • Added links to Japanese documentation, thanks @hideyukisaito!
  • Added; the express(1) generated app outputs the env
  • Added content-negotiation example
  • Dependency: connect >= 1.5.1 < 2.0.0
  • Fixed view layout bug. Closes #720
  • Fixed; ignore body on 304. Closes #701

2.3.11 / 2011-06-04

  • Added npm test
  • Removed generation of dummy test file from express(1)
  • Fixed; express(1) adds express as a dep
  • Fixed; prune on prepublish

2.3.10 / 2011-05-27

  • Added req.route, exposing the current route
  • Added package.json generation support to express(1)
  • Fixed call to app.param() function for optional params. Closes #682

2.3.9 / 2011-05-25

  • Fixed bug-ish with ../' inres.partial()` calls

2.3.8 / 2011-05-24

  • Fixed app.options()

2.3.7 / 2011-05-23

  • Added route Collection, ex: app.get('/user/:id').remove();
  • Added support for app.param(fn) to define param logic
  • Removed app.param() support for callback with return value
  • Removed module.parent check from express(1) generated app. Closes #670
  • Refactored router. Closes #639

2.3.6 / 2011-05-20

  • Changed; using devDependencies instead of git submodules
  • Fixed redis session example
  • Fixed markdown example
  • Fixed view caching, should not be enabled in development

2.3.5 / 2011-05-20

  • Added export .view as alias for .View

2.3.4 / 2011-05-08

  • Added ./examples/say
  • Fixed res.sendfile() bug preventing the transfer of files with spaces

2.3.3 / 2011-05-03

  • Added "case sensitive routes" option.
  • Changed; split methods supported per rfc [slaskis]
  • Fixed route-specific middleware when using the same callback function several times

2.3.2 / 2011-04-27

  • Fixed view hints

2.3.1 / 2011-04-26

  • Added app.match() as app.match.all()
  • Added app.lookup() as app.lookup.all()
  • Added app.remove() for app.remove.all()
  • Added app.remove.VERB()
  • Fixed template caching collision issue. Closes #644
  • Moved router over from connect and started refactor

2.3.0 / 2011-04-25

  • Added options support to res.clearCookie()
  • Added res.helpers() as alias of res.locals()
  • Added; json defaults to UTF-8 with res.send(). Closes #632. [Daniel * Dependency connect >= 1.4.0
  • Changed; auto set Content-Type in res.attachement [Aaron Heckmann]
  • Renamed "cache views" to "view cache". Closes #628
  • Fixed caching of views when using several apps. Closes #637
  • Fixed gotcha invoking app.param() callbacks once per route middleware. Closes #638
  • Fixed partial lookup precedence. Closes #631 Shaw]

2.2.2 / 2011-04-12

  • Added second callback support for res.download() connection errors
  • Fixed filename option passing to template engine

2.2.1 / 2011-04-04

  • Added layout(path) helper to change the layout within a view. Closes #610
  • Fixed partial() collection object support. Previously only anything with .length would work. When .length is present one must still be aware of holes, however now { collection: {foo: 'bar'}} is valid, exposes keyInCollection and keysInCollection.

  • Performance improved with better view caching

  • Removed request and response locals
  • Changed; errorHandler page title is now Express instead of Connect

2.2.0 / 2011-03-30

  • Added app.lookup.VERB(), ex app.lookup.put('/user/:id'). Closes #606
  • Added app.match.VERB(), ex app.match.put('/user/12'). Closes #606
  • Added app.VERB(path) as alias of app.lookup.VERB().
  • Dependency connect >= 1.2.0

2.1.1 / 2011-03-29

  • Added; expose err.view object when failing to locate a view
  • Fixed res.partial() call next(err) when no callback is given [reported by aheckmann]
  • Fixed; res.send(undefined) responds with 204 [aheckmann]

2.1.0 / 2011-03-24

  • Added <root>/_?<name> partial lookup support. Closes #447
  • Added request, response, and app local variables
  • Added settings local variable, containing the app's settings
  • Added req.flash() exception if req.session is not available
  • Added res.send(bool) support (json response)
  • Fixed stylus example for latest version
  • Fixed; wrap try/catch around res.render()

2.0.0 / 2011-03-17

  • Fixed up index view path alternative.
  • Changed; res.locals() without object returns the locals

2.0.0rc3 / 2011-03-17

  • Added res.locals(obj) to compliment res.local(key, val)
  • Added res.partial() callback support
  • Fixed recursive error reporting issue in res.render()

2.0.0rc2 / 2011-03-17

  • Changed; partial() "locals" are now optional
  • Fixed SlowBuffer support. Closes #584 [reported by tyrda01]
  • Fixed .filename view engine option [reported by drudge]
  • Fixed blog example
  • Fixed {req,res}.app reference when mounting [Ben Weaver]

2.0.0rc / 2011-03-14

  • Fixed; expose HTTPSServer constructor
  • Fixed express(1) default test charset. Closes #579 [reported by secoif]
  • Fixed; default charset to utf-8 instead of utf8 for lame IE [reported by NickP]

2.0.0beta3 / 2011-03-09

  • Added support for res.contentType() literal The original res.contentType('.json'), res.contentType('application/json'), and res.contentType('json') will work now.
  • Added res.render() status option support back
  • Added charset option for res.render()
  • Added .charset support (via connect 1.0.4)
  • Added view resolution hints when in development and a lookup fails
  • Added layout lookup support relative to the page view. For example while rendering ./views/user/index.jade if you create ./views/user/layout.jade it will be used in favour of the root layout.
  • Fixed res.redirect(). RFC states absolute url [reported by unlink]
  • Fixed; default res.send() string charset to utf8
  • Removed Partial constructor (not currently used)

2.0.0beta2 / 2011-03-07

  • Added res.render() .locals support back to aid in migration process
  • Fixed flash example

2.0.0beta / 2011-03-03

  • Added HTTPS support
  • Added res.cookie() maxAge support
  • Added req.header() Referrer / Referer special-case, either works
  • Added mount support for res.redirect(), now respects the mount-point
  • Added union() util, taking place of merge(clone()) combo
  • Added stylus support to express(1) generated app
  • Added secret to session middleware used in examples and generated app
  • Added res.local(name, val) for progressive view locals
  • Added default param support to req.param(name, default)
  • Added app.disabled() and app.enabled()
  • Added app.register() support for omitting leading ".", either works
  • Added res.partial(), using the same interface as partial() within a view. Closes #539
  • Added app.param() to map route params to async/sync logic
  • Added; aliased app.helpers() as app.locals(). Closes #481
  • Added extname with no leading "." support to res.contentType()
  • Added cache views setting, defaulting to enabled in "production" env
  • Added index file partial resolution, eg: partial('user') may try views/user/index.jade.
  • Added req.accepts() support for extensions
  • Changed; res.download() and res.sendfile() now utilize Connect's static file server connect.static.send().
  • Changed; replaced connect.utils.mime() with npm mime module
  • Changed; allow req.query to be pre-defined (via middleware or other parent
  • Changed view partial resolution, now relative to parent view
  • Changed view engine signature. no longer engine.render(str, options, callback), now engine.compile(str, options) -> Function, the returned function accepts fn(locals).
  • Fixed req.param() bug returning Array.prototype methods. Closes #552
  • Fixed; using Stream#pipe() instead of sys.pump() in res.sendfile()
  • Fixed; using qs module instead of querystring
  • Fixed; strip unsafe chars from jsonp callbacks
  • Removed "stream threshold" setting

1.0.8 / 2011-03-01

  • Allow req.query to be pre-defined (via middleware or other parent app)
  • "connect": ">= 0.5.0 < 1.0.0". Closes #547
  • Removed the long deprecated EXPRESS_ENV support

1.0.7 / 2011-02-07

  • Fixed render() setting inheritance. Mounted apps would not inherit "view engine"

1.0.6 / 2011-02-07

  • Fixed view engine setting bug when period is in dirname

1.0.5 / 2011-02-05

  • Added secret to generated app session() call

1.0.4 / 2011-02-05

  • Added qs dependency to package.json
  • Fixed namespaced require()s for latest connect support

1.0.3 / 2011-01-13

  • Remove unsafe characters from JSONP callback names [Ryan Grove]

1.0.2 / 2011-01-10

  • Removed nested require, using connect.router

1.0.1 / 2010-12-29

  • Fixed for middleware stacked via createServer() previously the foo middleware passed to createServer(foo) would not have access to Express methods such as res.send() or props like req.query etc.

1.0.0 / 2010-11-16

  • Added; deduce partial object names from the last segment. For example by default partial('forum/post', postObject) will give you the post object, providing a meaningful default.
  • Added http status code string representation to res.redirect() body
  • Added; res.redirect() supporting text/plain and text/html via Accept.
  • Added req.is() to aid in content negotiation
  • Added partial local inheritance [suggested by masylum]. Closes #102 providing access to parent template locals.
  • Added -s, --session[s] flag to express(1) to add session related middleware
  • Added --template flag to express(1) to specify the template engine to use.
  • Added --css flag to express(1) to specify the stylesheet engine to use (or just plain css by default).
  • Added app.all() support [thanks aheckmann]
  • Added partial direct object support. You may now partial('user', user) providing the "user" local, vs previously partial('user', { object: user }).
  • Added route-separation example since many people question ways to do this with CommonJS modules. Also view the blog example for an alternative.
  • Performance; caching view path derived partial object names
  • Fixed partial local inheritance precedence. [reported by Nick Poulden] Closes #454
  • Fixed jsonp support; text/javascript as per mailinglist discussion

1.0.0rc4 / 2010-10-14

  • Added _NODEENV support, _EXPRESSENV is deprecated and will be removed in 1.0.0
  • Added route-middleware support (very helpful, see the docs)
  • Added jsonp callback setting to enable/disable jsonp autowrapping [Dav Glass]
  • Added callback query check on response.send to autowrap JSON objects for simple webservice implementations [Dav Glass]
  • Added partial() support for array-like collections. Closes #434
  • Added support for swappable querystring parsers
  • Added session usage docs. Closes #443
  • Added dynamic helper caching. Closes #439 [suggested by maritz]
  • Added authentication example
  • Added basic Range support to res.sendfile() (and res.download() etc)
  • Changed; express(1) generated app using 2 spaces instead of 4
  • Default env to "development" again [aheckmann]
  • Removed context option is no more, use "scope"
  • Fixed; exposing ./support libs to examples so they can run without installs
  • Fixed mvc example

1.0.0rc3 / 2010-09-20

  • Added confirmation for express(1) app generation. Closes #391
  • Added extending of flash formatters via app.flashFormatters
  • Added flash formatter support. Closes #411
  • Added streaming support to res.sendfile() using sys.pump() when >= "stream threshold"
  • Added stream threshold setting for res.sendfile()
  • Added res.send() HEAD support
  • Added res.clearCookie()
  • Added res.cookie()
  • Added res.render() headers option
  • Added res.redirect() response bodies
  • Added res.render() status option support. Closes #425 [thanks aheckmann]
  • Fixed res.sendfile() responding with 403 on malicious path
  • Fixed res.download() bug; when an error occurs remove Content-Disposition
  • Fixed; mounted apps settings now inherit from parent app [aheckmann]
  • Fixed; stripping Content-Length / Content-Type when 204
  • Fixed res.send() 204. Closes #419
  • Fixed multiple Set-Cookie headers via res.header(). Closes #402
  • Fixed bug messing with error handlers when listenFD() is called instead of listen(). [thanks guillermo]

1.0.0rc2 / 2010-08-17

  • Added app.register() for template engine mapping. Closes #390
  • Added res.render() callback support as second argument (no options)
  • Added callback support to res.download()
  • Added callback support for res.sendfile()
  • Added support for middleware access via express.middlewareName() vs connect.middlewareName()
  • Added "partials" setting to docs
  • Added default expresso tests to express(1) generated app. Closes #384
  • Fixed res.sendfile() error handling, defer via next()
  • Fixed res.render() callback when a layout is used [thanks guillermo]
  • Fixed; make install creating ~/.node_libraries when not present
  • Fixed issue preventing error handlers from being defined anywhere. Closes #387

1.0.0rc / 2010-07-28

  • Added mounted hook. Closes #369
  • Added connect dependency to package.json

  • Removed "reload views" setting and support code development env never caches, production always caches.

  • Removed param in route callbacks, signature is now simply (req, res, next), previously (req, res, params, next). Use req.params for path captures, req.query for GET params.

  • Fixed "home" setting

  • Fixed middleware/router precedence issue. Closes #366
  • Fixed; configure() callbacks called immediately. Closes #368

1.0.0beta2 / 2010-07-23

  • Added more examples
  • Added; exporting Server constructor
  • Added Server#helpers() for view locals
  • Added Server#dynamicHelpers() for dynamic view locals. Closes #349
  • Added support for absolute view paths
  • Added; home setting defaults to Server#route for mounted apps. Closes #363
  • Added Guillermo Rauch to the contributor list
  • Added support for "as" for non-collection partials. Closes #341
  • Fixed install.sh, ensuring _~/.nodelibraries exists. Closes #362 [thanks jf]
  • Fixed res.render() exceptions, now passed to next() when no callback is given [thanks guillermo]
  • Fixed instanceof Array checks, now Array.isArray()
  • Fixed express(1) expansion of public dirs. Closes #348
  • Fixed middleware precedence. Closes #345
  • Fixed view watcher, now async [thanks aheckmann]

1.0.0beta / 2010-07-15

  • Re-write
    • much faster
    • much lighter
    • Check ExpressJS.com for migration guide and updated docs

0.14.0 / 2010-06-15

  • Utilize relative requires
  • Added Static bufferSize option [aheckmann]
  • Fixed caching of view and partial subdirectories [aheckmann]
  • Fixed mime.type() comments now that ".ext" is not supported
  • Updated haml submodule
  • Updated class submodule
  • Removed bin/express

0.13.0 / 2010-06-01

  • Added node v0.1.97 compatibility
  • Added support for deleting cookies via Request#cookie('key', null)
  • Updated haml submodule
  • Fixed not-found page, now using using charset utf-8
  • Fixed show-exceptions page, now using using charset utf-8
  • Fixed view support due to fs.readFile Buffers
  • Changed; mime.type() no longer accepts ".type" due to node extname() changes

0.12.0 / 2010-05-22

  • Added node v0.1.96 compatibility
  • Added view helpers export which act as additional local variables
  • Updated haml submodule
  • Changed ETag; removed inode, modified time only
  • Fixed LF to CRLF for setting multiple cookies
  • Fixed cookie complation; values are now urlencoded
  • Fixed cookies parsing; accepts quoted values and url escaped cookies

0.11.0 / 2010-05-06

  • Added support for layouts using different engines
    • this.render('page.html.haml', { layout: 'super-cool-layout.html.ejs' })
    • this.render('page.html.haml', { layout: 'foo' }) // assumes 'foo.html.haml'
    • this.render('page.html.haml', { layout: false }) // no layout
  • Updated ext submodule
  • Updated haml submodule
  • Fixed EJS partial support by passing along the context. Issue #307

0.10.1 / 2010-05-03

  • Fixed binary uploads.

0.10.0 / 2010-04-30

  • Added charset support via Request#charset (automatically assigned to 'UTF-8' when respond()'s encoding is set to 'utf8' or 'utf-8'.
  • Added "encoding" option to Request#render(). Closes #299
  • Added "dump exceptions" setting, which is enabled by default.
  • Added simple ejs template engine support
  • Added error reponse support for text/plain, application/json. Closes #297
  • Added callback function param to Request#error()
  • Added Request#sendHead()
  • Added Request#stream()
  • Added support for Request#respond(304, null) for empty response bodies
  • Added ETag support to Request#sendfile()
  • Added options to Request#sendfile(), passed to fs.createReadStream()
  • Added filename arg to Request#download()
  • Performance enhanced due to pre-reversing plugins so that plugins.reverse() is not called on each request
  • Performance enhanced by preventing several calls to toLowerCase() in Router#match()
  • Changed; Request#sendfile() now streams
  • Changed; Renamed Request#halt() to Request#respond(). Closes #289
  • Changed; Using sys.inspect() instead of JSON.encode() for error output
  • Changed; run() returns the http.Server instance. Closes #298
  • Changed; Defaulting Server#host to null (INADDR_ANY)
  • Changed; Logger "common" format scale of 0.4f
  • Removed Logger "request" format
  • Fixed; Catching ENOENT in view caching, preventing error when "views/partials" is not found
  • Fixed several issues with http client
  • Fixed Logger Content-Length output
  • Fixed bug preventing Opera from retaining the generated session id. Closes #292

0.9.0 / 2010-04-14

  • Added DSL level error() route support
  • Added DSL level notFound() route support
  • Added Request#error()
  • Added Request#notFound()
  • Added Request#render() callback function. Closes #258
  • Added "max upload size" setting
  • Added "magic" variables to collection partials (__index__, __length__, __isFirst__, __isLast__). Closes #254
  • Added haml.js submodule; removed haml-js
  • Added callback function support to Request#halt() as 3rd/4th arg
  • Added preprocessing of route param wildcards using param(). Closes #251
  • Added view partial support (with collections etc)
  • Fixed bug preventing falsey params (such as ?page=0). Closes #286
  • Fixed setting of multiple cookies. Closes #199
  • Changed; view naming convention is now NAME.TYPE.ENGINE (for example page.html.haml)
  • Changed; session cookie is now httpOnly
  • Changed; Request is no longer global
  • Changed; Event is no longer global
  • Changed; "sys" module is no longer global
  • Changed; moved Request#download to Static plugin where it belongs
  • Changed; Request instance created before body parsing. Closes #262
  • Changed; Pre-caching views in memory when "cache view contents" is enabled. Closes #253
  • Changed; Pre-caching view partials in memory when "cache view partials" is enabled
  • Updated support to node --version 0.1.90
  • Updated dependencies
  • Removed set("session cookie") in favour of use(Session, { cookie: { ... }})
  • Removed utils.mixin(); use Object#mergeDeep()

0.8.0 / 2010-03-19

  • Added coffeescript example app. Closes #242
  • Changed; cache api now async friendly. Closes #240
  • Removed deprecated 'express/static' support. Use 'express/plugins/static'

0.7.6 / 2010-03-19

  • Added Request#isXHR. Closes #229
  • Added make install (for the executable)
  • Added express executable for setting up simple app templates
  • Added "GET /public/*" to Static plugin, defaulting to <root>/public
  • Added Static plugin
  • Fixed; Request#render() only calls cache.get() once
  • Fixed; Namespacing View caches with "view:"
  • Fixed; Namespacing Static caches with "static:"
  • Fixed; Both example apps now use the Static plugin
  • Fixed set("views"). Closes #239
  • Fixed missing space for combined log format
  • Deprecated Request#sendfile() and 'express/static'
  • Removed Server#running

0.7.5 / 2010-03-16

  • Added Request#flash() support without args, now returns all flashes
  • Updated ext submodule

0.7.4 / 2010-03-16

  • Fixed session reaper
  • Changed; class.js replacing js-oo Class implementation (quite a bit faster, no browser cruft)

0.7.3 / 2010-03-16

  • Added package.json
  • Fixed requiring of haml / sass due to kiwi removal

0.7.2 / 2010-03-16

  • Fixed GIT submodules (HAH!)

0.7.1 / 2010-03-16

  • Changed; Express now using submodules again until a PM is adopted
  • Changed; chat example using millisecond conversions from ext

0.7.0 / 2010-03-15

  • Added Request#pass() support (finds the next matching route, or the given path)
  • Added Logger plugin (default "common" format replaces CommonLogger)
  • Removed Profiler plugin
  • Removed CommonLogger plugin

0.6.0 / 2010-03-11

  • Added seed.yml for kiwi package management support
  • Added HTTP client query string support when method is GET. Closes #205

  • Added support for arbitrary view engines. For example "foo.engine.html" will now require('engine'), the exports from this module are cached after the first require().

  • Added async plugin support

  • Removed usage of RESTful route funcs as http client get() etc, use http.get() and friends

  • Removed custom exceptions

0.5.0 / 2010-03-10

  • Added ext dependency (library of js extensions)
  • Removed extname() / basename() utils. Use path module
  • Removed toArray() util. Use arguments.values
  • Removed escapeRegexp() util. Use RegExp.escape()
  • Removed process.mixin() dependency. Use utils.mixin()
  • Removed Collection
  • Removed ElementCollection
  • Shameless self promotion of ebook "Advanced JavaScript" (http://dev-mag.com) ;)

0.4.0 / 2010-02-11

  • Added flash() example to sample upload app
  • Added high level restful http client module (express/http)
  • Changed; RESTful route functions double as HTTP clients. Closes #69
  • Changed; throwing error when routes are added at runtime
  • Changed; defaulting render() context to the current Request. Closes #197
  • Updated haml submodule

0.3.0 / 2010-02-11

  • Updated haml / sass submodules. Closes #200
  • Added flash message support. Closes #64
  • Added accepts() now allows multiple args. fixes #117
  • Added support for plugins to halt. Closes #189
  • Added alternate layout support. Closes #119
  • Removed Route#run(). Closes #188
  • Fixed broken specs due to use(Cookie) missing

0.2.1 / 2010-02-05

  • Added "plot" format option for Profiler (for gnuplot processing)
  • Added request number to Profiler plugin
  • Fixed binary encoding for multi-part file uploads, was previously defaulting to UTF8
  • Fixed issue with routes not firing when not files are present. Closes #184
  • Fixed process.Promise -> events.Promise

0.2.0 / 2010-02-03

  • Added parseParam() support for name[] etc. (allows for file inputs with "multiple" attr) Closes #180
  • Added Both Cache and Session option "reapInterval" may be "reapEvery". Closes #174
  • Added expiration support to cache api with reaper. Closes #133
  • Added cache Store.Memory#reap()
  • Added Cache; cache api now uses first class Cache instances
  • Added abstract session Store. Closes #172
  • Changed; cache Memory.Store#get() utilizing Collection
  • Renamed MemoryStore -> Store.Memory
  • Fixed use() of the same plugin several time will always use latest options. Closes #176

0.1.0 / 2010-02-03

  • Changed; Hooks (before / after) pass request as arg as well as evaluated in their context
  • Updated node support to 0.1.27 Closes #169
  • Updated dirname(filename) -> dirname
  • Updated libxmljs support to v0.2.0
  • Added session support with memory store / reaping
  • Added quick uid() helper
  • Added multi-part upload support
  • Added Sass.js support / submodule
  • Added production env caching view contents and static files
  • Added static file caching. Closes #136
  • Added cache plugin with memory stores
  • Added support to StaticFile so that it works with non-textual files.
  • Removed dirname() helper
  • Removed several globals (now their modules must be required)

0.0.2 / 2010-01-10

  • Added view benchmarks; currently haml vs ejs
  • Added Request#attachment() specs. Closes #116
  • Added use of node's parseQuery() util. Closes #123
  • Added make init for submodules
  • Updated Haml
  • Updated sample chat app to show messages on load
  • Updated libxmljs parseString -> parseHtmlString
  • Fixed make init to work with older versions of git
  • Fixed specs can now run independant specs for those who cant build deps. Closes #127
  • Fixed issues introduced by the node url module changes. Closes 126.
  • Fixed two assertions failing due to Collection#keys() returning strings
  • Fixed faulty Collection#toArray() spec due to keys() returning strings
  • Fixed make test now builds libxmljs.node before testing

0.0.1 / 2010-01-03

  • Initial release