Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: APIRoute type problems #3343

Closed
1 task
RafidMuhymin opened this issue May 11, 2022 · 1 comment · Fixed by #3344 or #3365
Closed
1 task

🐛 BUG: APIRoute type problems #3343

RafidMuhymin opened this issue May 11, 2022 · 1 comment · Fixed by #3344 or #3365
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@RafidMuhymin
Copy link
Member

What version of astro are you using?

1.0.0-beta.27

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm

What operating system are you using?

Zorin OS

Describe the Bug

The API Pages Documentation demonstrates the usage of the APIRoute type. But it's not been exported.

But even if I manually export the APIRoute type editing the files inside the astro package, it still doesn't work properly.

Screenshot_2022-05-11_19-43-51

Currently, the below code can be used as a workaround:

image

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-egzhia?file=src%2Fpages%2Fapi%2Freproduction.ts&on=stackblitz

Participation

  • I am willing to submit a pull request for this issue.
@matthewp matthewp changed the title 🐛 BUG: 🐛 BUG: APIRoute type problems May 11, 2022
@matthewp matthewp self-assigned this May 11, 2022
@matthewp matthewp added the - P4: important Violate documented behavior or significantly impacts performance (priority) label May 11, 2022
@shiftlabs1
Copy link

shiftlabs1 commented May 22, 2022

Should APIRoute type not be

export declare type APIRoute = (context: APIContext) => EndpointOutput | Response | Promise<EndpointOutput > | Promise<Response>;

It currently doesn't work for async/await functions . are all API methods synchronous by design ?
Screenshot 2022-05-22 at 2 46 55 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants