Skip to content
This repository has been archived by the owner on Jan 20, 2020. It is now read-only.

Static file serving compatible with koa-router.

License

Notifications You must be signed in to change notification settings

matpratta/koa-router-static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-router-static

Static file serving compatible with koa-router.

WARNING

This project is no longer maintained. It's been a long time and there are probably much better ways to do this today. Please refer to https://github.com/pkoretic/koa-static-server instead.

Usage

Simply use the middleware in your router and choose a directory. The module will already find the file you requested and serve it for you.

Full-code example:

var router require('koa-router')();
var serve = require('koa-router-static');

$.get('/*', serve('./assets/'));

In this case, the contents of the assets directory will be made available for your route.

You can also stack more than one serve (in case you want to have different assets for each route):

var router require('koa-router')();
var serve = require('koa-router-static');

$.get('/*', serve('./images/'));
$.get('/*', serve('./assets/'));

About

Static file serving compatible with koa-router.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published