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

feat(server-routes): add global default inputs #321

Merged
merged 5 commits into from
Jul 20, 2023

Conversation

arashsheyda
Copy link
Member

ability to add global inputs and save it on storage options

global-inputs-demo.mp4

const parsedQuery = computed(() => {
return {
...parseInputs(routeInputs.query),
...parseInputs(globalInputs.value.query),
Copy link
Member

Choose a reason for hiding this comment

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

I think the global input should have lower priority than local inputs

@@ -39,5 +39,10 @@ export const defaultTabOptions: NuxtDevToolsOptions = {
serverRoutes: {
selectedRoute: null,
view: 'tree',
globalInputs: {
Copy link
Member

Choose a reason for hiding this comment

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

It seems this default object isn't merged deep, and causing undefined error when first access

Copy link
Member

Choose a reason for hiding this comment

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

Also, maybe name it inputDefaults than globalInputs?

Copy link
Member Author

Choose a reason for hiding this comment

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

@antfu thanks for the points <3, I did resolve them except I'm not sure what is causing the undefined error(Tried the tab-server-route playground with no fs storage, and didn't get any error)
would changing the type of inputDefaults in options.ts help?

inputDefaults: Record<string, ServerRouteInput[]>
to
inputDefaults: { query: ServerRouteInput[] body: ServerRouteInput[] headers: ServerRouteInput[] }

@antfu antfu changed the title feat(server-routes): add global inputs feat(server-routes): add global default inputs Jul 20, 2023
@antfu antfu merged commit 80a284f into nuxt:main Jul 20, 2023
3 checks passed
@arashsheyda arashsheyda deleted the feat/server-routes-global-inputs branch July 20, 2023 11:26
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.

None yet

2 participants