Skip to content

Commit 7451b25

Browse files
author
Trygve Lie
committed
fix: Move Podium processing to a preHandler hook
1 parent 572b2f1 commit 7451b25

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/layout-plugin.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ const fp = require('fastify-plugin');
88

99
const podiumLayoutFastifyPlugin = (fastify, layout, done) => {
1010
// Decorate reply with .app.podium we can write to throught the request
11-
fastify.decorateReply('app', {
12-
podium: {},
11+
fastify.decorateReply('app', null);
12+
fastify.addHook('onRequest', async (request, reply) => {
13+
reply.app = {
14+
podium: {},
15+
}
1316
});
1417

1518
// Run parsers on request and store state object on reply.app.podium
16-
fastify.addHook('onRequest', async (request, reply) => {
19+
fastify.addHook('preHandler', async (request, reply) => {
1720
const incoming = new utils.HttpIncoming(
18-
request.req,
19-
reply.res,
21+
request.raw,
22+
reply.raw,
2023
reply.app.params,
2124
);
2225
reply.app.podium = await layout.process(incoming, { proxy: false });

0 commit comments

Comments
 (0)