I managed to have something working for my use case (rest API): http://localhost:3000/api/articles/1/highlights/2
Folder structure:
- articles
- index.ts
- [article_id]
- index.ts
- highlights
- index.ts
- [highlight_id].ts
[article_id]/index.ts file
import type { NextApiRequest, NextApiResponse } from "next";
const handler = async (req: NextApiRequest, res: NextApiResponse): Promise<void> => {
const { article_id } = req.query
return res.status(200).json(`article: ${article_id}`);
};
export default handler;
highlights/[highlight_id].ts file
import type { NextApiRequest, NextApiResponse } from "next";
const handler = async (req: NextApiRequest, res: NextApiResponse): Promise<void> => {
const { highlight_id } = req.query
return res.status(200).json(`highlight: ${highlight_id}`);
};
export default handler;