solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

API routes have to be inline exported function declarations

Open nnmrts opened this issue 1 year ago • 0 comments

Describe the bug

This works

export async function GET(...parameters) {
  console.log(parameters);

  return new Response("test", { status: 200 });
};

while this doesn't

const GET = async (...parameters) => {
  console.log(parameters);

  return new Response("test", { status: 200 });
};

export { GET };

Your Example Website or App

n/a

Steps to Reproduce the Bug or Issue

  1. Create the second code example as an API route.
  2. Observe it responding with this
{
  "statusCode": 500,
  "stack": []
}

Expected behavior

It should just work like the first code example. Internally, this library probably uses function names instead of named export names to determine the endpoint functions. It shouldn't.

Screenshots or Videos

No response

Platform

  • OS: macOS Sequoia
  • Browser: Chrome
  • Version: 1.0.6

Additional context

No response

nnmrts avatar Jul 22 '24 13:07 nnmrts