@tablecraft/adapter-next 0.1.0-beta.1 → 0.1.0-beta.2

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.
Files changed (2) hide show
  1. package/README.md +70 -1
  2. package/package.json +4 -3
package/README.md CHANGED
@@ -1,13 +1,32 @@
1
1
  # @tablecraft/adapter-next
2
2
 
3
- Next.js App Router adapter for [TableCraft](https://github.com/your-org/tablecraft).
3
+ Next.js App Router adapter for TableCraft — build powerful data APIs in your Next.js application.
4
+
5
+ ## Links
6
+
7
+ - [GitHub](https://github.com/jacksonkasi1/TableCraft)
8
+ - [Documentation](https://jacksonkasi.gitbook.io/tablecraft/)
4
9
 
5
10
  ## Install
6
11
 
7
12
  ```bash
8
13
  bun add @tablecraft/engine @tablecraft/adapter-next
14
+ # or
15
+ npm install @tablecraft/engine @tablecraft/adapter-next
16
+ # or
17
+ yarn add @tablecraft/engine @tablecraft/adapter-next
18
+ # or
19
+ pnpm add @tablecraft/engine @tablecraft/adapter-next
9
20
  ```
10
21
 
22
+ ## Features
23
+
24
+ - **App Router support** — Native Next.js App Router integration
25
+ - **Dynamic routes** — Single endpoint for multiple tables
26
+ - **Type-safe** — Full TypeScript support
27
+ - **Server-side rendering** — Works with SSR and SSG
28
+ - **Edge runtime** — Compatible with Edge runtime
29
+
11
30
  ## Usage
12
31
 
13
32
  ### Dynamic route (multiple tables)
@@ -37,6 +56,9 @@ export const GET = handler;
37
56
  ```ts
38
57
  // app/api/users/route.ts
39
58
  import { createNextRouteHandler } from '@tablecraft/adapter-next';
59
+ import { db } from '@/db';
60
+ import * as schema from '@/db/schema';
61
+ import { usersConfig } from '@/tablecraft.config';
40
62
 
41
63
  export const GET = createNextRouteHandler({
42
64
  db,
@@ -45,9 +67,56 @@ export const GET = createNextRouteHandler({
45
67
  });
46
68
  ```
47
69
 
70
+ ### With NextAuth.js
71
+
72
+ ```ts
73
+ // app/api/data/[table]/route.ts
74
+ import { createNextHandler } from '@tablecraft/adapter-next';
75
+ import { getServerSession } from 'next-auth';
76
+ import { authOptions } from '@/lib/auth';
77
+
78
+ const handler = createNextHandler({
79
+ db,
80
+ schema,
81
+ configs,
82
+ getContext: async (request) => {
83
+ const session = await getServerSession(authOptions);
84
+ return {
85
+ tenantId: session?.user?.tenantId,
86
+ user: session?.user,
87
+ };
88
+ },
89
+ });
90
+
91
+ export const GET = handler;
92
+ ```
93
+
48
94
  ### Query from the client
49
95
 
50
96
  ```
51
97
  GET /api/data/users?page=1&pageSize=25&sort=-createdAt&filter[status]=active&search=john
52
98
  GET /api/data/orders?export=csv
99
+ GET /api/data/products?filter[category]=electronics&filter[price][gte]=100
53
100
  ```
101
+
102
+ ## Configuration Options
103
+
104
+ ```ts
105
+ createNextHandler({
106
+ db, // Drizzle database instance
107
+ schema, // Drizzle schema object
108
+ configs, // Table configs map
109
+ getContext: async (request) => ({
110
+ tenantId: string,
111
+ user: { id: string, roles: string[] },
112
+ }),
113
+ onError: (error, request) => {
114
+ // Custom error handling
115
+ console.error(error);
116
+ },
117
+ });
118
+ ```
119
+
120
+ ## License
121
+
122
+ MIT
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@tablecraft/adapter-next",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.2",
4
4
  "description": "Next.js App Router adapter for TableCraft",
5
5
  "main": "dist/index.js",
6
- "module": "dist/index.mjs",
6
+ "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
@@ -12,7 +12,8 @@
12
12
  }
13
13
  },
14
14
  "files": [
15
- "dist"
15
+ "dist",
16
+ "README.md"
16
17
  ],
17
18
  "scripts": {
18
19
  "build": "bun run --bun tsc",