Skip to content

xiaohu-developer/fastify-static

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastify-static-xh

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

About

Plugin for serving static file as fast as possible

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.3%
  • HTML 1.7%