Closed marthendalnunes closed 1 year ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Updated (UTC) |
---|---|---|---|
light-turbo-eth | ✅ Ready (Inspect) | Visit Preview | Jun 12, 2023 6:27pm |
turbo-eth | ✅ Ready (Inspect) | Visit Preview | Jun 12, 2023 6:27pm |
This PR transitions the API endpoints from the
pages
router to the newapp
router, marking TurboETH's complete migration to theapp
router and eliminating thepages
folder. This move also standardizes the implementation of API endpoints for integrations.Now, every API endpoint associated with an integration should be located inside the
integrations
folder. For instance, if theopenai
integration requires anask
endpoint, the corresponding code should be housed inintegrations/openai/api/ask.ts
. The endpoint functions must maintain the Next convention for route handlers, employing named exports based on the HTTP method (GET, POST, PATCH, etc.):To expose the endpoint, the route handler file must reside at
app/api/(integration-name)/(endpoint-name)/route/ts
. For instance, theopenai
endpoint should be atapp/api/openai/ask/route.ts
:This pattern applies to all migrated API endpoints and should be adhered to for any new additions.
The major obstacle in this migration was the lack of support for
app
router API endpoints from iron-session. The workaround employed thegetIronSession
method with an emptyResponse
object to retrieve thesession
object, instead of using the unsupportedwithIronSessionApiRoute
wrapper. Upon the launch of iron-session V8, which promises first-class support for theapp
router, the endpoints utilizing it will be updated accordingly.