lime-static
Version:
Static file server for node.js REST servers using OWIN-JS framework for Project limerun
73 lines (52 loc) • 2.09 kB
Markdown
# [](http://limerun.com) lime-static
[](https://app.shippable.com/projects/54e7af9f5ab6cc13528d31ed/builds/latest)
[](http://owinjs.org)
[](https://nodei.co/npm/limerun/)
[](https://owind.org/)
[](https://nodei.co/npm/lime-static/)
## About
This is a simple static file router for [OWIN-JS](http://owinjs.org) REST framework for the `limerun` project
## Installation
```js
$ npm install lime-static
```
## Usage
```js
var static = require('lime-static');
app.use(static(filePath, options));
```
## Options
- `maxage` Browser cache max-age in milliseconds. defaults to 0
- `hidden` Allow transfer of hidden files. defaults to false
- `index` Default file name, defaults to 'index.html'
- `defer` If true, serves after `yield next`, allowing any downstream middleware to respond first
- `sync` If true uses node fs synchronous calls, if false uses asynchronous
## Example
``` js
// Dependencies
const lime = require('limerun')
, static = require('lime-static')
, http = require('http');
// Create Factories
var app = new lime.app();
// App
app.use(static('.'));
http.createServer(app.buildHttp()).listen(8000);
```
## Example with mount location
```js
// Dependencies
const lime = require('limerun')
, static = require('lime-static')
, http = require('http');
// Create Factories
var app = new lime.app();
// Mount app to map URL /bootstrap to file system directory \lib\vendor\bootstrap
app.mount('/bootstrap', function(applet){
applet.use(static('./lib/vendor/bootstrap', {sync:true}));
});
// Run app using standard owinJS host
http.createServer(app.buildHttp()).listen(8000);
```
## License
Apache 2.0