import { getAppById } from '~/data/apps'

export default defineEventHandler((event) => {
  const id = getRouterParam(event, 'id')

  if (!id) {
    throw createError({
      statusCode: 400,
      message: 'App ID is required',
    })
  }

  const app = getAppById(id)

  if (!app) {
    throw createError({
      statusCode: 404,
      message: 'App not found',
    })
  }

  return app
})
