diff --git a/packages/fastify-htmx/index.js b/packages/fastify-htmx/index.js index 247a62d0..c2849786 100644 --- a/packages/fastify-htmx/index.js +++ b/packages/fastify-htmx/index.js @@ -20,6 +20,18 @@ async function prepareClient(clientModule, scope, config) { } const { routes } = clientModule for (const route of routes) { + // Predecorate Request and Reply objects + if (route.decorateRequest) { + for (const prop of route.decorateRequest) { + !scope.hasRequestDecorator(prop) && scope.decorateRequest(prop, null) + } + } + if (route.decorateReply) { + for (const prop of route.decorateReply) { + !scope.hasReplyDecorator(prop) && scope.decorateReply(prop, null) + } + } + // Pregenerate prefetching elements const { css, svg, js } = await findClientImports( config.vite.root, route.modulePath, diff --git a/packages/fastify-htmx/package.json b/packages/fastify-htmx/package.json index 3ac71cde..e0814ac9 100644 --- a/packages/fastify-htmx/package.json +++ b/packages/fastify-htmx/package.json @@ -6,7 +6,7 @@ "main": "index.js", "name": "@fastify/htmx", "description": "The official @fastify/vite renderer for HTMX", - "version": "0.1.0", + "version": "0.2.0", "files": [ "virtual/layouts/default.jsx", "virtual/client.js",