From 57b72a57449f00938dd80c17c9c138ecee8a2ad4 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Tue, 7 Apr 2015 12:37:45 -0400 Subject: Add static file serving --- app/node_modules/okserver/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/node_modules/okserver/index.js') diff --git a/app/node_modules/okserver/index.js b/app/node_modules/okserver/index.js index ba4dd46..952602d 100644 --- a/app/node_modules/okserver/index.js +++ b/app/node_modules/okserver/index.js @@ -39,7 +39,23 @@ function OKServer(options) { throw new Error('View doesn\'t provide middleware'); router[mount](route, handler); }); + + /** + * Mount our middleware. + * Order is important here! Requests go down the middleware + * chain until they are handled with a response, which could + * happen anywhere in the chain. Watch out for middleware shadowing + * ither middleware. + */ + + // Serve user static files + app.use(express.static(root)); + // Serve admin interface static files + app.use(adminPath, express.static(adminRoot)); + // Application router app.use(router); + // Make sure this lady is last. Checks whether the desired + // route has a trailing-slash counterpart and redirects there app.use(slash()); /** -- cgit v1.2.3-70-g09d2