-
Notifications
You must be signed in to change notification settings - Fork 408
feat(2.0): seroval json mode #2042
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
Open
lxsmnsyc
wants to merge
21
commits into
main
Choose a base branch
from
feat-seroval-json
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3eca797
add seroval json mode
lxsmnsyc b22bb73
Update server-runtime.ts
lxsmnsyc 1d5c88a
Create plenty-geese-enter.md
lxsmnsyc 91c17a4
Fix client-server comms
lxsmnsyc d90c103
Add tests
lxsmnsyc 935ffa0
Add new header
lxsmnsyc 31c15ab
Update server-functions-handler.ts
lxsmnsyc ff263f7
Clone requests/responses
lxsmnsyc e11dfb3
Add more formats
lxsmnsyc 932dcd2
Fix `File` encoding
lxsmnsyc 8cb05af
Update server-functions-handler.ts
lxsmnsyc bfaf652
Update server-runtime.ts
lxsmnsyc df68b5b
Fix `FormData` missing boundary
lxsmnsyc e3ce6db
Add form-data test
lxsmnsyc 99966a2
fix tests
lxsmnsyc 265cf07
Bump `seroval` to `1.5.0`
lxsmnsyc 7ad4f09
Bump `seroval-plugins`
lxsmnsyc c4c02ba
Add bidirectional encoding
lxsmnsyc a56ba83
Fix error
lxsmnsyc 0defa47
Update server-functions-shared.ts
lxsmnsyc fce37a8
fix copilot suggestions
lxsmnsyc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@solidjs/start": minor | ||
| --- | ||
|
|
||
| seroval json mode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,4 +67,18 @@ test.describe("server-function", () => { | |||||||||||||||
| await page.goto("http://localhost:3000/generator-server-function"); | ||||||||||||||||
| await expect(page.locator("#server-fn-test")).toContainText("¡Hola, Mundo!"); | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| test("should build with a server function ping", async ({ page }) => { | ||||||||||||||||
| await page.goto("http://localhost:3000/server-function-ping"); | ||||||||||||||||
| await expect(page.locator("#server-fn-test")).toContainText('{"result":true}'); | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| test("should build with a server function w/ form data", async ({ page }) => { | ||||||||||||||||
| await page.goto("http://localhost:3000/server-function-form-data"); | ||||||||||||||||
| await expect(page.locator("#server-fn-test")).toContainText('{"result":true}'); | ||||||||||||||||
| }); | ||||||||||||||||
|
||||||||||||||||
| }); | |
| }); | |
| test("should build with a server function w/ blob data", async ({ page }) => { | |
| await page.goto("http://localhost:3000/server-function-blob"); | |
| await expect(page.locator("#server-fn-test")).toContainText('{"result":true}'); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { createEffect, createSignal } from "solid-js"; | ||
|
|
||
| async function ping(value: Blob) { | ||
| "use server"; | ||
| return value; | ||
| } | ||
|
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yMy0yMSAxMy0zNHonIGZpbGw9J3VybCgjZCknLz48L3N2Zz4="; | ||
|
|
||
| export default function App() { | ||
| const [output, setOutput] = createSignal<{ result?: boolean }>({}); | ||
|
|
||
| createEffect(async () => { | ||
| const request = await fetch(blobURI); | ||
| const blob = await request.blob(); | ||
| const result = await ping(blob); | ||
| const value = await blob.text(); | ||
| const test = await result.text(); | ||
|
|
||
| setOutput(prev => ({ ...prev, result: value === test })); | ||
| }); | ||
|
|
||
| return ( | ||
| <main> | ||
| <span id="server-fn-test">{JSON.stringify(output())}</span> | ||
| </main> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { createEffect, createSignal } from "solid-js"; | ||
|
|
||
| async function ping(value: FormData) { | ||
| "use server"; | ||
| const file = value.get("example") as File; | ||
| return await file.text(); | ||
| } | ||
|
|
||
| export default function App() { | ||
| const [output, setOutput] = createSignal<{ result?: boolean }>({}); | ||
|
|
||
| createEffect(async () => { | ||
| const file = new File(["Hello, World!"], "hello-world.txt"); | ||
| const formData = new FormData(); | ||
| formData.append("example", file); | ||
| const result = await ping(formData); | ||
| const value = await file.text(); | ||
| setOutput(prev => ({ ...prev, result: value === result })); | ||
| }); | ||
|
|
||
| return ( | ||
| <main> | ||
| <span id="server-fn-test">{JSON.stringify(output())}</span> | ||
| </main> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { createEffect, createSignal } from "solid-js"; | ||
|
|
||
| async function ping(value: string) { | ||
| "use server"; | ||
|
|
||
| return await Promise.resolve(value); | ||
| } | ||
|
|
||
| export default function App() { | ||
| const [output, setOutput] = createSignal<{ result?: boolean }>({}); | ||
|
|
||
| createEffect(async () => { | ||
| const value = `${Math.random() * 1000}`; | ||
| const result = await ping(value); | ||
| setOutput(prev => ({ ...prev, result: value === result })); | ||
| }); | ||
|
|
||
| return ( | ||
| <main> | ||
| <span id="server-fn-test">{JSON.stringify(output())}</span> | ||
| </main> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
New assertions use single-quoted string literals, but the repo formatter config uses double quotes (
singleQuote: false). Please update these to double quotes to avoid formatting churn.