Skip to content

Commit

Permalink
docs: Improved conciseness and readability (QwikDev#6404)
Browse files Browse the repository at this point in the history
* docs: Improved conciseness and readability

Rewrote the server$() section to be more concise and easier to read.

* Linted codebase with pnpm fmt
  • Loading branch information
codyroberts authored May 27, 2024
1 parent 6238394 commit 41339fe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
1 change: 0 additions & 1 deletion packages/create-qwik/src/helpers/jokes.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,4 @@
["Man said: I changed my Mind, Machine replied: I changed my CPU"],
["Man said: I dreamed of God, Machine replied: I dreamed of Rust"],
["Person: give me just a second, Programmer: give me just a 100 milliseconds"]

]
6 changes: 2 additions & 4 deletions packages/docs/src/routes/docs/(qwikcity)/server$/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ created_at: '2023-03-29T02:35:29Z'

# `server$()`

`server$()` allows you to create a function that always execute on the server, making it a great place to access the DB or perform server-only actions.

`server$` is a form of RPC (Remote Procedure Call) mechanism between the client and server, just like a traditional HTTP endpoint but strongly typed thanks to Typescript, and easier to maintain.
`server$()` allows you to define functions that execute exclusively on the server, making it ideal for server-only operations and database access. It functions as an RPC (Remote Procedure Call) mechanism between the client and server, similar to a traditional HTTP endpoint, but strongly typed with TypeScript and easier to maintain.

Your new function will have the following signature:
`([AbortSignal, ] ...): Promise<T>`
Expand Down Expand Up @@ -145,7 +143,7 @@ This API is actually used to implement QwikGPT streaming responses in our docs s

## How does `server$()` work?

A `server$()` wraps a function and returns an async proxy to the function. On the server, the proxy function directly calls the wrapped function, and a HTTP endpoint is automatically created by the `server$()` function.
`server$()` wraps a function and returns an async proxy to the function. On the server, the proxy function directly calls the wrapped function, and a HTTP endpoint is automatically created by the `server$()` function.

On the client, the proxy function invokes the wrapped function via an HTTP request, using `fetch()`.

Expand Down

0 comments on commit 41339fe

Please sign in to comment.