1.1.1 • Published 9 months ago

@kakang/fastify-static v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@kakang/fastify-static

Continuous Integration NPM version

This plugin provide serving file through different engine.

You can checkout @fastify/static if you prefer offcial plugin.

Install

npm install @kakang/fastify-static --save

yarn add @kakang/fastify-static

Usage

import FastifyStatic, {
  FileSystemEngine
} from '@kakang/fastify-static'

fastify.register(FastifyStatic, {
  serve: "/",
  root: "/",
  engine: new FileSystemEngine()
})

fastify.get("/download.txt", (_, reply) => {
  // download file
  return reply.download('download.txt', 'newname.txt')
})

fastify.get("/download.html", (_, reply) => {
  // send file
  return reply.sendFile('download.html')
})

fastify.post('/stream', (request, reply) => {
  // write file
  await fastify.static.upload('newfile.txt', request.body)
  return reply.send({ ok: true })
})
1.1.1

9 months ago

1.1.0

9 months ago

1.0.0

9 months ago

0.0.2

9 months ago