Files
Luke SandbergandGitHub eaad5b4c14 Enable prettier for turbopack (#78559)
Enable prettier for turbopack

While the majority of the javascript in turbopack is for tests, this code is generally hand authored so prettier will help us.  There are also core parts of turbopack implemented in JavaScript/TypeScript so a formatter will help.

This was done by simply fixing prettier ignore and chasing lint errors.  There were a few fun issues

* We had a test file called `won't-run-tla.js` and this triggered a bug in our eslint precommit hook.  The simplest thing was to simply drop the `'` character so that is what i did.  I spent a small amount of time trying to narrow this down't in the `lint-staged` dependency but failed, so i think the problem is probably in `eslint`, but it isn't really clear.
* We had another test exercising `import.meta` but in a file called `.cjs`, which prettier rejects due its default `babel` parser.  So i excluded this from prettier.
2025-04-29 11:38:46 -07:00

33 lines
831 B
JavaScript

import dbConnect from '../../../lib/dbConnect'
import Pet from '../../../models/Pet'
export default async function handler(req, res) {
const { method } = req
await dbConnect()
switch (method) {
case 'GET':
try {
const pets = await Pet.find({}) /* find all the data in our database */
res.status(200).json({ success: true, data: pets })
} catch (error) {
res.status(400).json({ success: false })
}
break
case 'POST':
try {
const pet = await Pet.create(
req.body
) /* create a new model in the database */
res.status(201).json({ success: true, data: pet })
} catch (error) {
res.status(400).json({ success: false })
}
break
default:
res.status(400).json({ success: false })
break
}
}