Server: chatcopsNext(), one catch-all route for Next.js
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
F-12 task 5. In Next.js the chat needs two route files today: app/api/chat/route.ts and app/api/chat/session/route.ts, which re-exports the first (website/src/content/docs/server/fetch-runtimes.mdx:13-40). Forgetting the second breaks session tokens. A Next adapter can serve every sub-path from one catch-all route:
// app/api/chat/[[...path]]/route.ts
import { chatcopsNext } from '@chatcops/server/next';
export const { POST, OPTIONS } = chatcopsNext({
provider: { type: 'claude', apiKey: process.env.ANTHROPIC_API_KEY! },
systemPrompt: 'You are a helpful assistant.',
sessionSecrets: [process.env.CHATCOPS_SESSION_SECRET!],
});
export const runtime = 'nodejs';
What to do
- A new
packages/server/src/adapters/next.tswithchatcopsNext(config), returning{ POST, OPTIONS }, both(request: Request) => Promise<Response>. Build it likechatcopsVercelHandler(packages/server/src/adapters/vercel.ts): onecreateChatHandlerat module scope, andfetchChatResponsewith the client IP.fetchChatResponsealready sends a path ending in/sessionto the session endpoint (isSessionPathinpackages/server/src/http.ts), so the catch-all works without routing of its own. Add aGETlater, with handoff (F-10). - Add
"./next"to theexportsinpackages/server/package.json, next to./vercel. - Docs: change the Next.js section of
fetch-runtimes.mdxto the single catch-all route, and keep the two-file version as a short note for older code.
Acceptance criteria
- Unit tests with real
Requestobjects: a chat POST to/api/chat, a session POST to/api/chat/session, anOPTIONSpreflight, and a request without a token getting 401 - You tried it in a fresh Next.js app (
npx create-next-app@latest), following the updated docs, and the widget chats with it. Say what you ran in the PR. -
pnpm docs:checkpasses (it checks that the server example setssessionSecrets) - A minor changeset for
@chatcops/server;pnpm test:coverage,pnpm lint,pnpm publintandpnpm api(commit the snapshot) pass
Comment on this issue to be assigned.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 13
- Forks
- 7
- Ø Merge
- 3 Std. 15 Min.
- Gemergte PRs (30 T.)
- 330
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus codercops/chatcops
-
Widget: a code block tagged `c++`, `c#` or `objective-c` shows part of the tag as codeEvtl. vergeben @prakashNalla hat das vor 1 Tag übernommen. Offenbug widget
codercops/chatcops#578 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Docs: Astro, Nuxt and SvelteKit guides for the serverEvtl. vergeben @anurag2787 hat das vor 1 Tag übernommen. Offendocumentation
codercops/chatcops#575 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
@chatcops/react: a <ChatCops> component and useChatCops() hookEvtl. vergeben @Saifjafri212213 hat das vor 1 Tag übernommen. Offenenhancement widget
codercops/chatcops#573 · 2 Kommentare · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 25/100
codercops/chatcops#546 · 5 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 64/100
codercops/chatcops#542 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in codercops/chatcops
Ähnliche Issues
-
area: frontend priority: normal
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
formbricks/formbricks#9918 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
thecodacus/pithagoras#364 ·
Maintainer antworten meist innerhalb von 1 Tag
-
TestAutonomousStop_ReportsObservedState fails under host load: 1s wall-clock ceiling vs 250ms cycleOffentype:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
nightgauge/nightgauge#2909 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag