Skip to content

Commit

Permalink
added plugin to access static files
Browse files Browse the repository at this point in the history
  • Loading branch information
tryb3l committed May 3, 2024
1 parent aff80b3 commit 6425d04
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@fastify/rate-limit": "^9.1.0",
"@fastify/sensible": "^5.6.0",
"@fastify/session": "^10.7.2",
"@fastify/static": "^7.0.3",
"@fastify/swagger": "^8.14.0",
"@fastify/swagger-ui": "3.0.0",
"@fastify/websocket": "^10.0.1",
Expand Down
18 changes: 18 additions & 0 deletions plugins/static.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const fp = require('fastify-plugin')
const fastifyStatic = require('@fastify/static')
const path = require('node:path')

module.exports = fp(
async function staticPlugin(fastify) {
fastify.register(fastifyStatic, {
root: path.join(__dirname, '../public'),
prefix: '/public/',
})
},
{
name: 'static',
dependencies: ['application-config'],
},
)

0 comments on commit 6425d04

Please sign in to comment.