@beignet/next 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +7 -0
- package/package.json +5 -3
- package/skills/routes-server/SKILL.md +134 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @beignet/next
|
|
2
2
|
|
|
3
|
+
## 0.0.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Ship TanStack Intent agent skills with Beignet packages and scaffold generated apps with Intent skill-loading guidance.
|
|
8
|
+
- @beignet/web@0.0.21
|
|
9
|
+
|
|
10
|
+
## 0.0.20
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- @beignet/web@0.0.20
|
|
15
|
+
|
|
3
16
|
## 0.0.19
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -32,6 +32,13 @@ npm install @beignet/next @beignet/core next
|
|
|
32
32
|
|
|
33
33
|
This package requires TypeScript 5.0 or higher for proper type inference.
|
|
34
34
|
|
|
35
|
+
## Agent skills
|
|
36
|
+
|
|
37
|
+
This package ships a TanStack Intent skill for coding agents:
|
|
38
|
+
`@beignet/next#routes-server`. Load it when wiring route groups, central route
|
|
39
|
+
registration, `createNextServer`, server context, OpenAPI/devtools routes,
|
|
40
|
+
Next catch-all API adapters, uploads, webhooks, or outbox drain routes.
|
|
41
|
+
|
|
35
42
|
## Quick start
|
|
36
43
|
|
|
37
44
|
### 1. Define your contracts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beignet/next",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Next.js server-side handlers for Beignet",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"!src/**/*.test.ts",
|
|
18
18
|
"!src/**/*.test.tsx",
|
|
19
19
|
"!src/**/*.test-d.ts",
|
|
20
|
+
"skills",
|
|
20
21
|
"README.md",
|
|
21
22
|
"CHANGELOG.md"
|
|
22
23
|
],
|
|
@@ -34,7 +35,8 @@
|
|
|
34
35
|
"typescript",
|
|
35
36
|
"next",
|
|
36
37
|
"nextjs",
|
|
37
|
-
"standard-schema"
|
|
38
|
+
"standard-schema",
|
|
39
|
+
"tanstack-intent"
|
|
38
40
|
],
|
|
39
41
|
"license": "MIT",
|
|
40
42
|
"repository": {
|
|
@@ -57,7 +59,7 @@
|
|
|
57
59
|
"next": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
58
60
|
},
|
|
59
61
|
"dependencies": {
|
|
60
|
-
"@beignet/web": "^0.0.
|
|
62
|
+
"@beignet/web": "^0.0.21",
|
|
61
63
|
"@standard-schema/spec": "^1.0.0"
|
|
62
64
|
},
|
|
63
65
|
"devDependencies": {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: routes-server
|
|
3
|
+
description: "Build Beignet Next.js server integration with @beignet/next: defineRouteGroup, defineRoutes, contractsFromRoutes, createNextServer, server context, hooks, OpenAPI/devtools routes, catch-all API adapters, uploads, webhooks, outbox drains, and route inspection. Use when wiring or debugging Beignet routes in a Next app."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Beignet Next Routes And Server
|
|
7
|
+
|
|
8
|
+
Use this skill when working in a Next.js app that depends on `@beignet/next`.
|
|
9
|
+
Read local `AGENTS.md`, `beignet.config.*`, and existing route/server files
|
|
10
|
+
before changing code.
|
|
11
|
+
|
|
12
|
+
## Route Shape
|
|
13
|
+
|
|
14
|
+
Feature route groups live beside the feature and map contracts to use cases.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { defineRouteGroup } from "@beignet/next";
|
|
18
|
+
import type { AppContext } from "@/app-context";
|
|
19
|
+
import { createProject, getProject } from "@/features/projects/contracts";
|
|
20
|
+
import {
|
|
21
|
+
createProjectUseCase,
|
|
22
|
+
getProjectUseCase,
|
|
23
|
+
} from "@/features/projects/use-cases";
|
|
24
|
+
import { auth } from "@/lib/route-auth";
|
|
25
|
+
|
|
26
|
+
export const projectRoutes = defineRouteGroup<AppContext>()({
|
|
27
|
+
name: "projects",
|
|
28
|
+
routes: [
|
|
29
|
+
{
|
|
30
|
+
contract: createProject,
|
|
31
|
+
hooks: [auth.required()],
|
|
32
|
+
useCase: createProjectUseCase,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
contract: getProject,
|
|
36
|
+
useCase: getProjectUseCase,
|
|
37
|
+
input: ({ path }) => ({ id: path.id }),
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Keep route entries thin: hooks, input mapping, policy checks, and use-case
|
|
44
|
+
binding. Business behavior belongs in use cases.
|
|
45
|
+
|
|
46
|
+
## Central Registry
|
|
47
|
+
|
|
48
|
+
Register feature route groups once in `server/routes.ts`.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { contractsFromRoutes, defineRoutes } from "@beignet/next";
|
|
52
|
+
import type { AppContext } from "@/app-context";
|
|
53
|
+
import { projectRoutes } from "@/features/projects/routes";
|
|
54
|
+
|
|
55
|
+
export const routes = defineRoutes<AppContext>([projectRoutes]);
|
|
56
|
+
export const contracts = contractsFromRoutes(routes);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
OpenAPI, typed clients, devtools, and route inspection should derive from this
|
|
60
|
+
registry. If a route is missing from OpenAPI or clients, check this file first.
|
|
61
|
+
|
|
62
|
+
## Server Composition
|
|
63
|
+
|
|
64
|
+
`server/index.ts` owns runtime composition:
|
|
65
|
+
|
|
66
|
+
- `createNextServer(...)`
|
|
67
|
+
- app ports
|
|
68
|
+
- providers
|
|
69
|
+
- hooks
|
|
70
|
+
- server context blueprint
|
|
71
|
+
- route registry
|
|
72
|
+
- response validation and error mapping
|
|
73
|
+
|
|
74
|
+
Keep app-specific infra wiring in `infra/` and `server/providers.ts`, not in
|
|
75
|
+
feature route files.
|
|
76
|
+
|
|
77
|
+
## Next Route Adapter
|
|
78
|
+
|
|
79
|
+
Application API routes usually use one catch-all file:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { server } from "@/server";
|
|
83
|
+
|
|
84
|
+
export const DELETE = server.api;
|
|
85
|
+
export const GET = server.api;
|
|
86
|
+
export const HEAD = server.api;
|
|
87
|
+
export const OPTIONS = server.api;
|
|
88
|
+
export const PATCH = server.api;
|
|
89
|
+
export const POST = server.api;
|
|
90
|
+
export const PUT = server.api;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The catch-all file is adapter glue. Contracts should still use explicit paths
|
|
94
|
+
such as `/projects/:id`, not catch-all contract patterns.
|
|
95
|
+
|
|
96
|
+
## Focused Routes
|
|
97
|
+
|
|
98
|
+
Focused route files are appropriate for framework helpers and specialized
|
|
99
|
+
HTTP surfaces:
|
|
100
|
+
|
|
101
|
+
- OpenAPI or Swagger UI
|
|
102
|
+
- devtools
|
|
103
|
+
- uploads
|
|
104
|
+
- storage object routes
|
|
105
|
+
- payment or webhook adapters
|
|
106
|
+
- outbox drains
|
|
107
|
+
- redirects or downloads
|
|
108
|
+
|
|
109
|
+
Use a route `handle` escape hatch only when the route intentionally returns a
|
|
110
|
+
native `Response`, streams, owns custom headers, or otherwise sits outside the
|
|
111
|
+
normal use-case binder.
|
|
112
|
+
|
|
113
|
+
## Context
|
|
114
|
+
|
|
115
|
+
`server/context.ts` should use `defineServerContext`. Request context reads the
|
|
116
|
+
session, creates an actor, attaches ports, request IDs, and trace context.
|
|
117
|
+
Service context is for schedules, tasks, outbox drains, and background work;
|
|
118
|
+
create a service actor and do not assume a request session.
|
|
119
|
+
|
|
120
|
+
## Debugging
|
|
121
|
+
|
|
122
|
+
- Route group exists but does not run: register it in `server/routes.ts`.
|
|
123
|
+
- Contract missing from OpenAPI: export `contracts = contractsFromRoutes(routes)`.
|
|
124
|
+
- `doctor` dislikes the route shape: use `defineRouteGroup<AppContext>()({ ... })`.
|
|
125
|
+
- Client code imports `server/`: move shared DTOs to schemas and call through
|
|
126
|
+
contracts and the typed client.
|
|
127
|
+
|
|
128
|
+
Run:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
beignet routes
|
|
132
|
+
beignet lint
|
|
133
|
+
beignet doctor --strict
|
|
134
|
+
```
|