Skip to content

Commit

Permalink
feat(htmx): ability to predecorate req and reply
Browse files Browse the repository at this point in the history
  • Loading branch information
galvez committed Feb 19, 2024
1 parent aafe1fa commit fb838ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/fastify-htmx/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <head> elements
const { css, svg, js } = await findClientImports(
config.vite.root,
route.modulePath,
Expand Down
2 changes: 1 addition & 1 deletion packages/fastify-htmx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit fb838ba

Please sign in to comment.