Skip to content

Commit

Permalink
fix: read static logo only then necessary (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
xpr0gamers authored Apr 2, 2024
1 parent 1b600f5 commit edeeacb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ const path = require('node:path')
const fp = require('fastify-plugin')
const csp = require('./static/csp.json')

async function fastifySwaggerUi (fastify, opts) {
const logoContent = await fsPromises.readFile(path.join(__dirname, './static/logo.svg'))

async function fastifySwaggerUi(fastify, opts) {
fastify.decorate('swaggerCSP', csp)

//if no logo is provided, read default static logo
let logoContent = opts.logo;
if (logoContent == null) {
const bufferLogoContent = await fsPromises.readFile(path.join(__dirname, './static/logo.svg'));
logoContent = { type: 'image/svg+xml', content: bufferLogoContent };
}

await fastify.register(require('./lib/routes'), {
prefix: opts.routePrefix || '/documentation',
uiConfig: opts.uiConfig || {},
initOAuth: opts.initOAuth || {},
hooks: opts.uiHooks,
theme: opts.theme || {},
logo: opts.logo || { type: 'image/svg+xml', content: logoContent },
logo: logoContent,
...opts
})
}
Expand Down

0 comments on commit edeeacb

Please sign in to comment.