AIFeed

Vercel Board 支持自带后端

AI summary

Vercel Board SDK 和 vercel board 命令现在可以接入你自己提供的后端。你自己后端上的 board 所提供的 API,与团队在 Vercel API 中的 board 相同。Postgres 是 SDK 首个随附的后端,可通过 postgres() 挂载到 API 路由上,但需要配合 blob 存储来存放文件;vercelBlob() 可将文件保存在私有的 Vercel Blob 存储中,每个文件最大 100 MB;vercelQueues() 则可在 Vercel Queues 上运行 board 的定时器(例如定时消息),需在单独的路由中挂载调度器,并从队列主题触发。

Translation(model translation, not the source's own text)
题图
题图

Vercel Board SDK 和 vercel board 命令现在可以接入你自己提供的后端。你自己后端上的看板所提供的 API,与团队在 Vercel API 中的看板相同。Postgres 是 SDK 首个内置支持的后端。

在 API 路由上用 postgres() 挂载看板。它需要一个 blob 存储来存放文件。vercelBlob() 将文件保存在私有的 Vercel Blob 存储中,单个文件最大 100 MB。vercelQueues() 在 Vercel Queues 上运行看板的定时任务,例如定时消息。


        import { board } from "@vercel/board";import { postgres } from "@vercel/board/backend-postgres";import { vercelBlob } from "@vercel/board/backend-postgres/blob-vercel";import { vercelQueues } from "@vercel/board/backend-postgres/scheduler-vercel";
export const scheduler = vercelQueues({ topic: "board" });export const team = board({ backend: postgres({ blob: vercelBlob(), scheduler }) });export const GET = team.fetch, POST = team.fetch;
      

在 Postgres、Vercel Blob 和 Vercel Queues 上挂载看板

将调度器挂载到单独的路由中,并从队列主题触发它:


        export { scheduler as POST } from "@/app/api/board/[[...path]]/route";
      

挂载调度器


        {  "functions": {    "app/api/board-scheduler/route.ts": {      "experimentalTriggers": [{ "type": "queue/v2beta", "topic": "board", "retryAfterSeconds": 30 }]    }  }}
      

从 Vercel Queues 触发调度器

在旁边安装 pg、@vercel/blob 和 @vercel/queue。postgres() 会读取 DATABASE_URL 或 POSTGRES_URL,或接受你传入的 connectionString 或 pg pool。在首次部署前应用包中附带的 schema,并使用提供商的池化连接 URL,因为每个实例最多会打开 10 个连接的池。

调用方默认通过 OIDC 认证。在 Vercel 上,你团队的人员和项目自身的部署可以访问,grants 则允许其他项目和 GitHub Actions 工作流访问。传入 authenticate 以你自己的方式验证调用方,当看板在 Vercel 之外运行时设置 url。用 --url 将 vercel board 指向你的路由。

升级到 @vercel/[email protected] 或更高版本以使用 Postgres 后端。在 Postgres 文档中了解更多。

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by Vercel Blog
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗