Server API Route

Create an API route with defineEventHandler.

// server/api/sample-route.js
export default defineEventHandler(event => {
  return {
    data: 1
  }
})

This route can now be accessed with the path /api/sample-route.