Koa-static-server
Static file serving middleware for KOA with directory, rewrite and index support
Koa-static-server
Static file serving middleware for KOA with directory, rewrite and index support
Installation
$ NPM Install Koa-static-server
Api
var koa = require (' KOA ') var app = Koa () App.use (Require (' koa-static ') (options))
Options
rootDir
{string} directory is served
rootPath
{string} optional rewrite path
log
{Boolean} request access log to console
maxage
Browser cache max-age in milliseconds. Defaults to 0
hidden
Allow transfer of hidden files. Defaults to False
gzip
Try to serve the gzipped version of a file automatically when was gzip
supported by a client and if the requested file wit H .gz
extension exists. defaults to True.
Example
See examples for code examples
Example ' Web ' directory//web/index.html//Web/file.txt var serve = require (' Koa-static-server ') var app = require (' KOA ') ()//root index support//GET///returns index.html//Get/file.txt//returns file.txt App.use (Serve ({rootdir: ' Web ') })//folder support//get/web///returns/web/index.html//get/web/file.txt//Returns/web/file.txt App.use (Serve ( {rootdir: ' Web ', RootPath: '/web '}) Index support//GET///Returns/file.txt App.use (Serve ({rootdir: ' Web ', Index: ' file.txt '})//rewrite support//G et/web///returns 404//Get/admin//Returns/admin/index.html App.use (Serve ({rootdir: ' Web ', RootPath: '/admin '})) AP P.listen (Console.log) (' Listening on Port 3000 ')
Support
- Issues-open New Issue
- IRC-On
pkoretic
freenode
License
MIT
Wemall Open Source Micro-mall, mall, mall source code, three levels of distribution, micro-fresh, micro-fruit, micro-takeaway, micro-ordering---professional system wemall Address: http://www.wemallshop.com
Code Address: Http://js.koahub.com/home/feature/koa-static-server
Koahub platform based on node. JS developed KOA rewrite and index support plug-in code details