@conorpai/koa-static-router

1.1.8 • Public • Published

koa-static-router

Static file serving middleware with router

Installation

$ npm install koa-static-router

Usage

A Single Router

 app.use(static({
     dir,
     route  
 }))

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',     //dir:static resource directory
    router    //router:router
},{
    dir,
    router  
}
]))

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
}
]))

Package Sidebar

Install

npm i @conorpai/koa-static-router

Weekly Downloads

1

Version

1.1.8

License

MIT

Unpacked Size

3.53 kB

Total Files

3

Last publish

Collaborators

  • conorpai