Skip to content

Commit

Permalink
fix docs build
Browse files Browse the repository at this point in the history
  • Loading branch information
nksaraf committed Oct 22, 2024
1 parent 92641b9 commit 51911c6
Show file tree
Hide file tree
Showing 9 changed files with 717 additions and 413 deletions.
9 changes: 5 additions & 4 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export default defineConfig({
{ text: "Vite Plugins", link: "/guide/vite-plugins" },
{ text: "Path Aliases", link: "/guide/aliases" },
{ text: "Route Rules", link: "/guide/route-rules" },
{ text: "File System Routing", link: "/guide/file-system-routing" },
{
text: "File System Routing",
link: "/guide/file-system-routing",
},
],
},
],
Expand Down Expand Up @@ -87,9 +90,7 @@ export default defineConfig({
level: [2, 3],
},

socialLinks: [
{ icon: "github", link: "https://github.com/nksaraf/vinxi" },
],
socialLinks: [{ icon: "github", link: "https://github.com/nksaraf/vinxi" }],
},
markdown: {
codeTransformers: [
Expand Down
6 changes: 3 additions & 3 deletions docs/api/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The `createApp` function return an instance of `App`. This instance has the foll

Starts the development server for the app.

```ts twoslash
```ts
import { createApp } from "vinxi";

const app = createApp({
Expand All @@ -61,7 +61,7 @@ await app.dev();

Builds the app for production.

```ts twoslash
```ts
import { createApp } from "vinxi";

const app = createApp({
Expand All @@ -77,7 +77,7 @@ await app.build();

Gets a router by name.

```ts twoslash
```ts
import { createApp } from "vinxi";

const app = createApp({
Expand Down
6 changes: 3 additions & 3 deletions docs/api/server/cookies.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Parse the request to get HTTP Cookie header string and returning an object of all cookie name-value pairs.

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, parseCookies } from "vinxi/http"

export default eventHandler(async (event) => {
Expand All @@ -30,7 +30,7 @@ export function parseCookies(event: HTTPEvent): Record<string, string>

Get a cookie value by name.

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, getCookie } from "vinxi/http"
export default eventHandler(async (event) => {
Expand All @@ -55,7 +55,7 @@ export function getCookie(event: HTTPEvent, name: string): string | undefined

Set a cookie value by name.

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, setCookie } from "vinxi/http"
export default eventHandler(async (event) => {
Expand Down
34 changes: 17 additions & 17 deletions docs/api/server/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Get the request headers

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, getRequestHeaders } from "vinxi/http";

export default eventHandler(async (event) => {
Expand All @@ -32,7 +32,7 @@ export function getRequestHeaders(event: HTTPEvent): RequestHeaders;

Get a request header by name

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, getRequestHeader } from "vinxi/http";

export default eventHandler(async (event) => {
Expand All @@ -59,7 +59,7 @@ export function getRequestHeader(

Reads request body and tries to safely parse as JSON using [destr](https://github.com/unjs/destr).

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, readBody } from "vinxi/http";

export default eventHandler(async (event) => {
Expand All @@ -85,7 +85,7 @@ function readBody<

Constructs a `FormData` object from an event, after converting it to a a web request.

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, readFormData } from "vinxi/http";

export default eventHandler(async (event) => {
Expand All @@ -109,7 +109,7 @@ export function readFormData(event: HTTPEvent): Promise<FormData>;

Tries to read and parse the body of an HTTPEvent as a multipart form.

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, readMultipartFormData } from "vinxi/http";

export default eventHandler(async (event) => {
Expand Down Expand Up @@ -142,7 +142,7 @@ Tries to read the request body via `readBody`, then uses the provided validation

#### Using `zod`

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, readValidatedBody } from "vinxi/http";
import { z } from "zod";

Expand All @@ -158,7 +158,7 @@ export default eventHandler(async (event) => {

#### Using custom validation function

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, readValidatedBody } from "vinxi/http";

//
Expand Down Expand Up @@ -213,7 +213,7 @@ function readRawBody<E extends Encoding = "utf8">(

Captures a [ReadableStream][readablestream] from a request.

```ts twoslash
```ts
import { eventHandler, getRequestWebStream } from "vinxi/http";

export default eventHandler(async (event) => {
Expand All @@ -223,7 +223,7 @@ export default eventHandler(async (event) => {

::: details Signature

```ts twoslash
```ts
// @lib: es2015
// @filename: index.d.ts
import { HTTPEvent } from "vinxi/http";
Expand All @@ -247,7 +247,7 @@ export function getRequestWebStream(

Get the query

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, getQuery } from "vinxi/http";

export default eventHandler(async (event) => {
Expand All @@ -273,7 +273,7 @@ export function getQuery<

Get the validated query

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, getValidatedQuery } from "vinxi/http";

export default eventHandler(async (event) => {
Expand Down Expand Up @@ -305,7 +305,7 @@ export function getValidatedQuery<

Get the request host

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, getRequestHost } from "vinxi/http";

export default eventHandler(async (event) => {
Expand All @@ -332,7 +332,7 @@ export function getRequestHost(

Get the request protocol, whether its `http` or `https`.

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, getRequestProtocol } from "vinxi/http";

export default eventHandler(async (event) => {
Expand All @@ -359,7 +359,7 @@ export function getRequestProtocol(

Get the request [URL][url]

```ts twoslash file=app/server.ts
```ts file=app/server.ts
// @noErrors
import { eventHandler, getRequestURL } from "vinxi/http";

Expand Down Expand Up @@ -399,7 +399,7 @@ export function getRequestURL(

Get the request IP, if visible.

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, getRequestIP } from "vinxi/http";

export default eventHandler(async (event) => {
Expand All @@ -424,7 +424,7 @@ export function getRequestIP(

Check if the request is a CORS preflight request

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { eventHandler, isPreflightRequest } from "vinxi/http";

export default eventHandler(async (event) => {
Expand All @@ -444,7 +444,7 @@ export function isPreflightRequest(event: HTTPEvent): boolean;

Get a Web Fetch API compliant [`Request`][request] instance from the [`HTTPEvent`][httpevent]

```ts twoslash
```ts
import { eventHandler, getWebRequest } from "vinxi/http";

export default eventHandler(async (event) => {
Expand Down
10 changes: 5 additions & 5 deletions docs/api/server/session.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Use the session to read and update the session data

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { type SessionConfig, eventHandler, useSession } from "vinxi/http"

const sessionConfig = {
Expand Down Expand Up @@ -50,7 +50,7 @@ export function useSession<T extends SessionDataT = SessionDataT>(

Get the session

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { type SessionConfig, eventHandler, getSession } from "vinxi/http"
const sessionConfig = {
Expand Down Expand Up @@ -88,7 +88,7 @@ export function getSession<T extends SessionDataT = SessionDataT>(

Update the session

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { type SessionConfig, eventHandler, updateSession } from "vinxi/http"
const sessionConfig = {
Expand Down Expand Up @@ -125,7 +125,7 @@ export function updateSession<T extends SessionDataT = SessionDataT>(

Clear the session

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { type SessionConfig, clearSession, eventHandler } from "vinxi/http"
const sessionConfig = {
Expand Down Expand Up @@ -158,7 +158,7 @@ export function sealSession(event: HTTPEvent, config: SessionConfig): void

Unseal the session

```ts twoslash file=app/server.ts
```ts file=app/server.ts
import { type SessionConfig, eventHandler, unsealSession } from "vinxi/http"
const sessionConfig = {
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/add-to-existing-vite-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The first step is to make your `vite` app into a `vinxi` app. You don't need to

Here is an example of a `vite.config.ts` file that exports the same `vite` app as a `vinxi` app:

```ts twoslash
```ts
import { createApp } from "vinxi";
import { config } from "vinxi/plugins/config";

Expand Down
6 changes: 3 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"author": "",
"license": "ISC",
"dependencies": {
"@shikijs/vitepress-twoslash": "^1.1.2",
"vinxi": "workspace:^",
"vitepress": "1.0.0-rc.42",
"@shikijs/vitepress-twoslash": "^1.22.0",
"vinxi": "0.4.3",
"vitepress": "1.4.1",
"vue": "^3.4.19"
},
"devDependencies": {
Expand Down
14 changes: 14 additions & 0 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"allowJs": true,
"checkJs": true,
"noEmit": true,
"isolatedModules": true
}
}
Loading

0 comments on commit 51911c6

Please sign in to comment.