Menu

1 / 2

Lessons Learned Building a Multi-Platform Publishing Tool with Fastify

DEV Community: fastify·Charles Yun·about 23 hours ago
#6c7hoxmZ
#devtofastify#devto#dev#fastify#fullscreen
Reading 0:00
15s threshold

I've been building a publishing tool , and I chose Fastify for the backend. The reasoning was simple: official plugins (jwt, cookie, cors) cover all the essentials, the performance reputation is solid, and TypeScript support is complete. Now that the P0 end-to-end flow is running, here are the pitfalls I hit along the way.

1. The second argument to register is not what you think

The most subtle pitfall. I wanted to protect a whole group of business routes with authentication, so I naturally wrote:

await app . register ( connectionRoutes , { preHandler : [ app . authenticate ] })

Enter fullscreen mode

Exit fullscreen mode

The result: every endpoint was wide open — unauthenticated requests got through. Digging into the docs revealed that the second options object of register is passed as an argument to the plugin function , not treated as route config.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.