Skip to content

Commit

Permalink
fix: make fastify plugins async instead of callback
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanvanherwijnen committed Jan 30, 2024
1 parent ffc9c5d commit 5629a80
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
12 changes: 3 additions & 9 deletions packages/vitrify/src/node/frameworks/vue/fastify-csr-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type {
FastifyPluginCallback,
FastifyRequest,
FastifyReply
} from 'fastify'
import type { FastifyPluginAsync, FastifyRequest, FastifyReply } from 'fastify'
import fastifyStatic from '@fastify/static'
import type { ViteDevServer } from 'vite'
import { fileURLToPath } from 'url'
Expand All @@ -21,10 +17,9 @@ export interface FastifySsrOptions {
mode?: string
}

const fastifyCsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
const fastifyCsrPlugin: FastifyPluginAsync<FastifySsrOptions> = async (
fastify,
options,
done
options
) => {
options.vitrifyDir =
options.vitrifyDir || (await import('vitrify')).vitrifyDir
Expand Down Expand Up @@ -64,7 +59,6 @@ const fastifyCsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
prefix: options.baseUrl
})
}
done()
}

export { fastifyCsrPlugin }
Expand Down
13 changes: 3 additions & 10 deletions packages/vitrify/src/node/frameworks/vue/fastify-ssr-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type {
FastifyPluginCallback,
FastifyRequest,
FastifyReply
} from 'fastify'
import type { FastifyPluginAsync, FastifyRequest, FastifyReply } from 'fastify'
import fastifyStatic from '@fastify/static'
import { readFileSync } from 'fs'
import { fileURLToPath } from 'url'
Expand Down Expand Up @@ -31,10 +27,9 @@ export interface FastifySsrOptions {
host?: string
}

const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
const fastifySsrPlugin: FastifyPluginAsync<FastifySsrOptions> = async (
fastify,
options,
done
options
) => {
options.baseUrl = options.baseUrl || '/'
options.mode = options.mode || process.env.MODE || import.meta.env.MODE
Expand Down Expand Up @@ -223,8 +218,6 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
res.send(html)
})
}

done()
}

export { fastifySsrPlugin }
Expand Down

0 comments on commit 5629a80

Please sign in to comment.