Skip to content

jsumners/fastify-static

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastify-static Build Status Greenkeeper badge Known Vulnerabilities

Plugin for serving static file

Install

npm install --save fastify-static

Usage

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

fastify.register(require('fastify-static'), {
  root: path.join(__dirname, 'public'),
  prefix: '/public/' // optional: default '/'
  page404Path: path.join(__dirname, 'public', '404.html'), // optional
  page403Path: path.join(__dirname, 'public', '403.html'), // optional
  page500Path: path.join(__dirname, 'public', '500.html')  // optional
})

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 95.3%
  • HTML 4.7%