Skip to content
This repository has been archived by the owner on Jul 31, 2018. It is now read-only.

Allow passing multiple parameters to app.use() #45

Closed
wants to merge 1 commit into from
Closed

Allow passing multiple parameters to app.use() #45

wants to merge 1 commit into from

Conversation

babolivier
Copy link
Contributor

@babolivier babolivier commented Apr 14, 2017

I just found myself in a case where I have to serve multiple static directories, each with a different path. Express's documentation tells us this can be done by passing the path as the first app.use() parameter:

app.use('/static', express.static('public'))

This PR allows Americano's config to do just this. If a path must be added to the static directory, the use configuration shall look like this:

use: [
    americano.bodyParser(),
    americano.methodOverride(),
    americano.static(__dirname + '/../../client/public', {
        maxAge: 86400000
    }),
    ['/static', americano.static(__dirname + '/../../testStatic', {
        maxAge: 86400000
    })]
]

In this example you can see how my client/public directory is being served statically without a path (so using the root), and my testStatic directory is being served statically on /static.

@babolivier babolivier closed this Apr 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant