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

fix(create-pages): e2e test createApi and fix method+path combos #1141

Merged
merged 10 commits into from
Jan 12, 2025

Conversation

tylersayshi
Copy link
Contributor

e2e tests for createApi usage in createPages

chore: remove default main.tsx from spec (happy to revert this if we want it there for some reason)

Copy link

vercel bot commented Jan 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
waku ✅ Ready (Inspect) Visit Preview Jan 12, 2025 2:30am

Copy link

codesandbox-ci bot commented Jan 9, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@tylersayshi tylersayshi changed the title test(create-pages): e2e tests for createApi fix(create-pages): e2e test createApi and fix method+path combos Jan 12, 2025

createApi({
path: '/api/empty',
mode: 'static',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably a doc issue, but if we use static mode, we recommend using file extension like /api/empty.txt. Otherwise, the static build will be /api/empty/index.html.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can enforce that with types, but I think docs are the right way to encourage that to start.

Comment on lines +154 to +166
params:
| {
path: Path;
mode: 'static';
method: 'GET';
handler: (req: Request) => Promise<Response>;
}
| {
path: Path;
mode: 'dynamic';
method: Method;
handler: (req: Request) => Promise<Response>;
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. We can even force file extension for path for static mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep! If we want

@@ -227,27 +236,26 @@ export const createPages = <
[PathSpec, FunctionComponent<any>]
>();
const apiPathMap = new Map<
string,
string, // `${method} ${path}`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems room for improvement, but just a nit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have any suggestions? this composite key approach feels a tiny bit tricky to use, but it solves the problem really well

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not right away. I'll let you know if something arises.

Copy link
Owner

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dai-shi dai-shi merged commit 014b0ad into dai-shi:main Jan 12, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants