express-route-builder
Advanced tools
Comparing version 0.0.6 to 0.0.7
13
index.js
@@ -54,2 +54,15 @@ 'use strict'; | ||
/* | ||
* Adds a static directory to the express app. | ||
*/ | ||
addStatic (dir, mountPath = null) { | ||
if (mountPath) { | ||
this.app.use(this.express.static(mountPath, dir)); | ||
} else { | ||
this.app.use(this.express.static(dir)); | ||
} | ||
} | ||
/* | ||
* Adds a route to the Express app. | ||
@@ -56,0 +69,0 @@ */ |
@@ -10,3 +10,3 @@ { | ||
"name": "express-route-builder", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Quickly compile Express.js routes with minimal code.", | ||
@@ -13,0 +13,0 @@ "keywords": [ |
@@ -50,2 +50,16 @@ # Express-Route-Builder | ||
## Static Files | ||
Serving up static files is very easy and uses the same arguments as `express.static()` except with the arguments reversed. To specify multiple static directories call the `.addStatic()` method multiple times. Files will be looked up in the order the directories are specified. | ||
```javascript | ||
// Adds a directory from which express will serve up your static files. | ||
// For "photo.jpg" the resulting URL will be "http://www.example.com/photo.jpg" | ||
// and the file will be served up from the directory specified. | ||
builder.addStatic('/path/to/static/directory'); | ||
// You can also specify a prefix to use in the URL as the second parameter. | ||
// This time "photo.jpg" will have a URL of "http://www.example.com/images/photos/photo.jpg" | ||
builder.addStatic('/path/to/static/directory', 'images/photos'); | ||
``` | ||
## API | ||
@@ -58,1 +72,4 @@ | ||
Adds a route to your Express app based on the path given; you can specify any path that Express accepts. The filename should be the name of the module which will handle this route, relative to the base path given in the constructor. Also, you can optionally specify an array of middleware functions to use before the route is processed. | ||
#### .addStatic(dir, prefix = null); | ||
Adds a directory to your express app where static files will be served up from. The directory will be relative to the `baseDir` specified in the constructor. The prefix parameter is optional and will be prepended to the file path in the URL, just like with express.static(). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7526
112
74