The Foo Playground Controller
I start my new projects by copy and pasting from previous projects. One of the first things I copy is this in my backend service:
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify"
import { LOGGER } from "@/plugins/logger"
const logger = LOGGER
//Placeholder to put temporary test code
export async function foo(
this: FastifyInstance,
request: FastifyRequest,
reply: FastifyReply
) {
logger.info("headers %o", request.headers)
logger.info("params %o", request.params)
logger.info("query %o", request.query)
logger.info("body %o", request.body)
return reply.send({})
}
It’s a convenient place for me to put some temporary/playground code and then trigger it with:
curl http://localhost:4002/foo
There’s also the additional benefit that I know to git reset --hard
the same file src/controllers/fooController.ts