Refactor to share handler logic in route-module (#79106)
This pulls the logic added in `templates/pages-api` that is needed to
support the `handler` interface into the `route-module` interface so
that it can shared with the other templates as the `handler` interface
is added for them as well.
Validated against deploy tests here:
https://github.com/vercel/vercel/actions/runs/14982451661/job/42089544277?pr=13326