Update
Hey folks, hope all is well out there. Today I want to go over a significant change to the DECAF API.
Over the last couple of months I’ve been working with Fastify a lot, and Hono a little. Over this period I have been falling for Fastify quite a bit. Out of the box, it handles a lot of the things I find myself fighting with within Express. So I have been reimplementing DECAF in Fastify and this will be the framework in use moving forward. I know this will introduce a couple of groans but it will streamline a lot of the work to get this over the finish line.
Some things I like:
First-class TypeScript support: Fastify is built around JSON Schema and lets you derive your request/response types directly from your schemas, so you get full end-to-end type safety right off the bat.
Schema-based validation & serialization: You declare your input/output shape once and Fastify automatically handles validation, coercion and serialization. No manual setup or custom wrappers.
Built-in lifecycle hooks: preHandler/onRequest/onResponse/etc. let you hook in cross-cutting concerns (auth, logging, long running jobs like brew cycles) without wrestling with middleware configs and timing. This is my favorite feature.
Plugins: Everything from CORS, Swagger/OpenAPI, WebSockets, JWT auth and more is a Fastify plugin. Install it, register it, and move on. Mostly.
Near automatic logging and docs with pino and swagger
There is no doubt that Express can do all of these things as well, I just find myself constantly working on setup, configs and middleware instead of pushing actual features and making progress.
I have pushed this latest version of DECAF here: https://github.com/margyle/mugsy-decaf
It will live here until I integrate the job queue that manages brews and hooks into Operator. Once that is complete, it will live in the main Mugsy org repo and be added to the eventual monorepo.
You can follow the readme and run it today to get a feel for how it works and how additional features are built. As usual, there is a ‘cats’ feature to demonstrate how to build new features, along with the current users, auth, recipes and recipe step endpoints.
API docs are available to see how requests and responses work:
I expect to have the MVP version of DECAF completed in two weeks or so. The current version should not be considered stable and breaking changes are likely. Once this is wrapped, we should be mostly caught up on where I wanted to be before the tariff PCB party.
Ok, that is all for now. Next update will be next weekend.
Cheers!