create-surf-app 1.0.0-alpha.31 → 1.0.0-alpha.32

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.
@@ -68,7 +68,28 @@ exports.users = pgTable("users", {
68
68
  ```
69
69
 
70
70
  Tables are auto-created on startup and when `schema.js` changes (file watcher).
71
- The agent can also call `POST /api/__sync-schema` explicitly after editing.
71
+
72
+ Query the database in routes using `@surf-ai/sdk/db` — **not** Drizzle ORM query builder:
73
+
74
+ ```js
75
+ const { dbQuery } = require("@surf-ai/sdk/db");
76
+
77
+ router.get("/", async (req, res) => {
78
+ const rows = await dbQuery("SELECT * FROM users ORDER BY created_at DESC");
79
+ res.json(rows);
80
+ });
81
+
82
+ router.post("/", async (req, res) => {
83
+ const { name } = req.body;
84
+ const [row] = await dbQuery(
85
+ "INSERT INTO users (name) VALUES ($1) RETURNING *",
86
+ [name]
87
+ );
88
+ res.json(row);
89
+ });
90
+ ```
91
+
92
+ Database runs through an HTTP proxy — there is no direct `db` connection object or `req.db` middleware. Use `dbQuery(sql, params)` for all reads and writes.
72
93
 
73
94
  ## Do NOT modify
74
95
 
@@ -5,7 +5,7 @@
5
5
  "dev": "node scripts/check-env.js node --watch server.js"
6
6
  },
7
7
  "dependencies": {
8
- "@surf-ai/sdk": "1.0.0-alpha.31",
8
+ "@surf-ai/sdk": "1.0.0-alpha.32",
9
9
  "express": "4.22.1"
10
10
  }
11
11
  }
@@ -72,6 +72,28 @@ export const users = pgTable("users", {
72
72
 
73
73
  Tables are auto-synced on server start and when `db/schema.ts` changes in dev mode.
74
74
 
75
+ Query the database in API routes using `@surf-ai/sdk/db` — **not** Drizzle ORM query builder:
76
+
77
+ ```ts
78
+ import { dbQuery } from "@surf-ai/sdk/db";
79
+
80
+ export async function GET() {
81
+ const rows = await dbQuery("SELECT * FROM users ORDER BY created_at DESC");
82
+ return Response.json(rows);
83
+ }
84
+
85
+ export async function POST(request: Request) {
86
+ const { name } = await request.json();
87
+ const [row] = await dbQuery(
88
+ "INSERT INTO users (name) VALUES ($1) RETURNING *",
89
+ [name]
90
+ );
91
+ return Response.json(row);
92
+ }
93
+ ```
94
+
95
+ Database runs through an HTTP proxy — there is no direct `db` connection object or `req.db` middleware. Use `dbQuery(sql, params)` for all reads and writes.
96
+
75
97
  ## Do NOT modify
76
98
 
77
99
  - `instrumentation.ts` - server boot (schema sync, cron)
@@ -8,7 +8,7 @@
8
8
  "type-check": "tsc --noEmit --incremental"
9
9
  },
10
10
  "dependencies": {
11
- "@surf-ai/sdk": "1.0.0-alpha.31",
11
+ "@surf-ai/sdk": "1.0.0-alpha.32",
12
12
  "@surf-ai/theme": "latest",
13
13
  "next": "15.5.14",
14
14
  "react": "19.2.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-surf-app",
3
- "version": "1.0.0-alpha.31",
3
+ "version": "1.0.0-alpha.32",
4
4
  "description": "Scaffold a Surf app — Vite + React + Express + @surf-ai/sdk",
5
5
  "type": "module",
6
6
  "bin": {