-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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. |
|
||
createApi({ | ||
path: '/api/empty', | ||
mode: 'static', |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
params: | ||
| { | ||
path: Path; | ||
mode: 'static'; | ||
method: 'GET'; | ||
handler: (req: Request) => Promise<Response>; | ||
} | ||
| { | ||
path: Path; | ||
mode: 'dynamic'; | ||
method: Method; | ||
handler: (req: Request) => Promise<Response>; | ||
}, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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)