egg-static-server
v1.0.0
Published
Static file serving middleware for egg with directory, rewrite and index support
Downloads
1
Readme
egg-static-server
Static server plugin for egg, base on koa-static-server
Install
$ npm i egg-static-server --save
Usage
// {app_root}/config/plugin.js
exports.staticServer = {
enable: true,
package: 'egg-static-server',
}
Configuration
egg-static-server client configurations below:
- rootDir {string} directory that is to be served
- rootPath {string} optional rewrite path
- notFoundFile {string} optional default file to serve if requested static is missing
- log {boolean} request access log to console
- maxage Browser cache max-age in milliseconds. defaults to
0
in other envs,31536000
in prod en - hidden Allow transfer of hidden files. defaults to
false
- gzip Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. defaults to
true
.
single client
// {app_root}/config/config.default.js
exports.staticServer = {
client: {
rootPath: 'xxx',
rootDir: 'xxx'
},
default: {
maxage: 125800
}
}
multi client
exports.staticServer = {
clients: {
foo: {
rootPath: 'xxx',
rootDir: 'xxx'
},
bar: {
rootPath: 'xxx',
rootDir: 'xxx'
}
},
default: {
maxage: 125800
}
}
see config/config.default.js for more detail.
Example
Questions & Suggestions
Please open an issue here.