Write a typescript nextjs module that implements api handler which returns the latest…
- User
Write a typescript nextjs module that implements api handler which returns the latest document from firestore collection "people". Firestore initialized and can be imported from '@db' package. Don't forget to provide file path where to paste the code. Ask more questions if something is not clear. Answer in json like this: {"additionalQuestions"?: string[], modules?: Array<{code: string, filePath: string}> }
Assistant
{"additionalQuestions": ["How should the response be structured?"], "modules": [{"code": "
typescript\nimport { NextApiHandler } from 'next';\nimport { Firestore } from '@db';\n\nconst handler: NextApiHandler = async (req, res) => {\n const peopleCollection = Firestore.collection('people');\n\n const latestDocument = await peopleCollection.orderBy('timestamp', 'desc').limit(1).get();\n\n const latestData = latestDocument.docs[0].data();\n\n res.status(200).json(latestData);\n};\nexport default handler;\n", "filePath": "./api/latest-person.ts"}]}
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.