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

docs: replace libc6-compat by gcompat in Dockerfile #433

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/getting-started/cloudflare-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,17 @@ bun run deploy
:::

### Deploy via the Cloudflare dashboard with GitHub

1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
2. In Account Home, select Workers & Pages > Create application > Pages > Connect to Git.
3. Authorize your GitHub account, and select the repository. In Set up builds and deployments, provide the following information:

| Configuration option | Value |
|----------------------|-----------------|
| -------------------- | --------------- |
| Production branch | `main` |
| Build command | `npm run build` |
| Build directory | `dist` |


## Bindings

You can use Cloudflare Bindings like Variables, KV, D1, and others.
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ FROM node:20-alpine AS base

FROM base AS builder

RUN apk add --no-cache libc6-compat
RUN apk add --no-cache gcompat
WORKDIR /app

COPY package*json tsconfig.json src ./
Expand Down
2 changes: 1 addition & 1 deletion docs/middleware/builtin/jwt.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The JWT Auth Middleware provides authentication by verifying the token with JWT.
The middleware will check for an `Authorization` header if the `cookie` option is not set.

:::info
The Authorization header sent from the client must have a specified scheme.
The Authorization header sent from the client must have a specified scheme.

Example: `Bearer my.token.value` or `Basic my.token.value`
:::
Expand Down
48 changes: 27 additions & 21 deletions examples/prisma.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,23 @@ DATABASE_URL="prisma://accelerate...."

Copy this `DATABASE_URL` and store it in `.dev.vars` and `.env` so that prisma cli can access it later on.


## Set Up Prisma in Your Project

The neon.tech URL you received can also be used as an alternative and provide Prisma with more options, so store it for later use:

::: code-group

::: code-group
```ts [.dev.vars]
DATABASE_URL="your_prisma_accelerate_url"
DIRECT_URL="your_neon_tech_url"
```
:::
```bash [.dev.vars]
DATABASE_URL="your_prisma_accelerate_url"
DIRECT_URL="your_neon_tech_url
```

:::

Now, go to your `schema.prisma` file and set the URLs like this:

::: code-group

```ts [schema.prisma]
generator client {
provider = "prisma-client-js"
Expand All @@ -74,46 +75,51 @@ datasource db {
directUrl = env("DIRECT_URL")
}
```

:::

Create a function like this, which you can use in your project later:

::: code-group

```ts [prismaFunction.ts]
import { PrismaClient } from '@prisma/client/edge'
import { withAccelerate } from '@prisma/extension-accelerate'

export const getPrisma = (database_url: string) => {
const prisma = new PrismaClient({
datasourceUrl: database_url,
}).$extends(withAccelerate());
return prisma
const prisma = new PrismaClient({
datasourceUrl: database_url,
}).$extends(withAccelerate())
return prisma
}
```

:::

Here is an example of how you can use this function in your project:

::: code-group

```ts [index.ts]
import { Hono } from 'hono';
import { sign, verify } from 'hono/jwt';
import { getPrisma } from '../usefulFun/prismaFun';
import { Hono } from 'hono'
import { sign, verify } from 'hono/jwt'
import { getPrisma } from '../usefulFun/prismaFun'

// Create the main Hono app
const app = new Hono<{
Bindings: {
DATABASE_URL: string
JWT_SECRET: string
},
}
Variables: {
userId: string,
userId: string
}
}>();
}>()

app.post('/', async (c) => {
// Now you can use it wherever you want
const prisma = getPrisma(c.env.DATABASE_URL);
});
// Now you can use it wherever you want
const prisma = getPrisma(c.env.DATABASE_URL)
})
```
:::

:::