0.2.0 • Published 7 years ago

fastify-static-xh v0.2.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

fastify-static Build Status Greenkeeper badge Known Vulnerabilities

Plugin for serving static file

What does this forked version changed

  • scan the folder and register each file separately. (Instead of {prefix}/*)
  • let system 404 handler handle the NOT FOUND situation

Install

npm install --save fastify-static-xh

Usage

const fastify = require('fastify')
const path = require('path')

fastify.register(require('fastify-static-xh'), {
  root: path.join(__dirname, 'public'),
  prefix: '/public/' // optional: default '/'
})

fastify.get('/another/path', function (req, reply) {
  reply.sendFile('myHtml.html') // serving path.join(__dirname, 'public', 'myHtml.html') directly
})

License

Licensed under MIT