1.5.0 • Published 3 years ago

koa-static-router v1.5.0

Weekly downloads
89
License
MIT
Repository
github
Last release
3 years ago

koa-static-router

npm.io npm.io

Static file serving middleware with router,wrapper for koa-send.【koa中间件,koa-static-router实现多个&&多层路由加载静态资源】

Installation

$ npm install koa-static-router

Usage

Simple Router

app.use(static('public'))

A Single Router

 app.use(static({
     dir:'public',    //dir:static resource directory
     router:'/'    //router:router
 }))

Multiple Router

please make sure that routing is same length when you choose Multiple Router (多个路由时,请确保路由长度相同)

'/static/' - >routing length = 1

'/static/image1/' - >routing length =2

app.use(static([
    {
    dir:'public',     //dir:static resource directory
    router:'/public/'    //router:router
},{
    dir:'static',
    router:'/static/'  
}
]))

Example

git clone git@github.com:Rise-Devin/koa-static-router.git
cd koa-static-router
npm install 
npm start

Access localhost:3000/public/image/dir/1.png npm.io Access localhost:3000/static/image/dir/2.png npm.io

const static = require('koa-static-router');

//   A Single Router
// app.use(static({
//     dir:'public',
//     router:'/static/'   
// }))


//Multiple Router
app.use(static([
    {
    dir:'public',     
    router:'/public/image/'   //routing length = 2
},{
    dir:'static',
    router:'/static/image/'   //routing length = 2
}
]))
1.4.4

3 years ago

1.5.0

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.0

5 years ago

1.2.0

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago