Last active
October 8, 2024 17:42
-
-
Save ProfAvery/7ac60e6aaefc0063be925862c2e78b5d to your computer and use it in GitHub Desktop.
Updated Listing 7-9 - Summer 2024 AMSE Bootcamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type {NextApiRequest, NextApiResponse, NextApiHandler} from "next"; | |
import {findByZip} from "./../../../../mongoose/weather/services"; | |
import dbConnect from "./../../../../middleware/db-connect"; | |
async function handler( | |
req: NextApiRequest, | |
res: NextApiResponse | |
): Promise<NextApiResponse<WeatherDetailType> | void> { | |
let data = await findByZip(req.query.zipcode as string); | |
return res.status(200).json(data); | |
} | |
const connectDB = (fn: NextApiHandler) => | |
async (req: NextApiRequest, res: NextApiResponse) => { | |
await dbConnect(); | |
return await fn(req, res); | |
}; | |
export default connectDB(handler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment