<repo_name>Mallaxy/NextJS<file_sep>/pages/api/echo/[id].ts
import {NextApiRequest, NextApiResponse} from 'next'

type Data = {
    yourId: string | string[]
}

export default function getById(req: NextApiRequest, res: NextApiResponse<Data>) {
    // res.statusCode = 200
    // res.setHeader('Content-Type', 'application/json')
    // res.end(req.query.id)
    res.json({yourId: req.query.id})
}
<file_sep>/pages/api/echo.ts
import {NextApiRequest, NextApiResponse} from 'next'

type Data = {
    message: string
}

export default function echo(req: NextApiRequest, res: NextApiResponse<Data>) {
    res.statusCode = 200
    res.setHeader('Content-Type', 'application/json')
    res.end(JSON.stringify({
        message: req.query.message ?? 'Base Message'
    }))
}
