summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorAlan Pearce2017-06-19 21:06:49 +0200
committerAlan Pearce2017-06-19 21:11:42 +0200
commitd2b9b7e3299a4d80655439c99c5de26a8c95e6f2 (patch)
tree0e9d4e0c5a86d284fde0f6172517046cdb43675f /src
parent7455233d74ffe056c4a5927c9272516fdc0e5dfc (diff)
downloadhomestead-d2b9b7e3299a4d80655439c99c5de26a8c95e6f2.tar.lz
homestead-d2b9b7e3299a4d80655439c99c5de26a8c95e6f2.tar.zst
homestead-d2b9b7e3299a4d80655439c99c5de26a8c95e6f2.zip
feat: Serve static files under ./static
Diffstat (limited to 'src')
-rw-r--r--src/index.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/index.js b/src/index.js
index 6622a79..8c69cc8 100644
--- a/src/index.js
+++ b/src/index.js
@@ -3,6 +3,8 @@
 const Koa = require('koa')
 const app = new Koa()
 
+const send = require('koa-send')
+
 const config = require('./modules/config.js')
 
 const PORT = process.env.PORT || config.server.port
@@ -59,6 +61,15 @@ for (let [term, items] of taxonomies) {
 
 app.use(router.routes()).use(router.allowedMethods())
 
+const prefix = /^\/static\//
+app.use(async function (ctx) {
+  if (prefix.test(ctx.path)) {
+    await send(ctx, ctx.path.replace(prefix, ''), {
+      root: './static'
+    })
+  }
+})
+
 module.exports = app
 
 if (require.main === module) {