{
"$type": "site.standard.document",
"path": "/the-foo-controller/",
"publishedAt": "2025-01-18T06:30:00.000Z",
"site": "at://did:plc:bryys25pc2fnagnyxqgsglhd/site.standard.publication/3mn26bjkkmh23",
"tags": [
"Techniques",
"Web"
],
"textContent": "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:\n\nimport { FastifyInstance, FastifyReply, FastifyRequest } from \"fastify\"\nimport { LOGGER } from \"@/plugins/logger\"\n\nconst logger = LOGGER\n\n//Placeholder to put temporary test code\nexport async function foo(\n this: FastifyInstance,\n request: FastifyRequest,\n reply: FastifyReply\n) {\n logger.info(\"headers %o\", request.headers)\n logger.info(\"params %o\", request.params)\n logger.info(\"query %o\", request.query)\n logger.info(\"body %o\", request.body)\n\n return reply.send({})\n}\n\nIt's a convenient place for me to put some temporary/playground code and then trigger it with:\n\ncurl http://localhost:4002/foo\n\nThere's also the additional benefit that I know to git reset --hard the same file src/controllers/fooController.ts",
"title": "The Foo Playground Controller"
}