// Next.js API route support: https://nextjs.org/docs/api-routes/introduction import { readFile } from "fs/promises"; import type { NextApiRequest, NextApiResponse } from "next"; export default async function handler( req: NextApiRequest, res: NextApiResponse ) { const { name } = req.query; const result = await readFile(`lessons/${name}.md`); const resultString = result.toString(); res.status(200).json({ contents: resultString }); }