@rip-lang/db 0.8.4 → 0.9.0
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/db.rip +20 -23
- package/package.json +1 -1
package/db.rip
CHANGED
|
@@ -155,10 +155,9 @@ executeSQL = (sql, params = []) ->
|
|
|
155
155
|
# ==============================================================================
|
|
156
156
|
|
|
157
157
|
# POST / — duck-ui compatible (raw SQL in body)
|
|
158
|
-
post '/'
|
|
159
|
-
sql = read
|
|
160
|
-
|
|
161
|
-
return { error: 'Empty query' } unless sql?.trim()
|
|
158
|
+
post '/' ->
|
|
159
|
+
sql = read 'body', 'string'
|
|
160
|
+
return { error: 'Empty query' } unless sql
|
|
162
161
|
executeSQL sql
|
|
163
162
|
|
|
164
163
|
# POST /sql — JSON body with optional params
|
|
@@ -239,15 +238,13 @@ get '/ui', -> new Response Bun.file(import.meta.dir + '/db.html')
|
|
|
239
238
|
# ==============================================================================
|
|
240
239
|
|
|
241
240
|
# POST /ddb/run — Execute SQL and return binary result (DuckDB UI protocol)
|
|
242
|
-
post '/ddb/run'
|
|
241
|
+
post '/ddb/run' ->
|
|
243
242
|
try
|
|
244
|
-
sql =
|
|
245
|
-
|
|
243
|
+
sql = read 'body', 'string'
|
|
244
|
+
return binaryResponse serializeErrorResult 'Empty query' unless sql
|
|
246
245
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
# Parse result row limit from headers
|
|
250
|
-
rowLimit = parseInt(req.headers.get('x-duckdb-ui-result-row-limit') or '10000')
|
|
246
|
+
# Parse row limit from DuckDB UI header
|
|
247
|
+
rowLimit = parseInt(@req.header('x-duckdb-ui-result-row-limit') or '10000')
|
|
251
248
|
|
|
252
249
|
# Execute query
|
|
253
250
|
conn = db.connect()
|
|
@@ -270,29 +267,29 @@ post '/ddb/run', (req) ->
|
|
|
270
267
|
finally
|
|
271
268
|
conn.close()
|
|
272
269
|
|
|
273
|
-
catch
|
|
274
|
-
console.error "POST /ddb/run error:",
|
|
275
|
-
binaryResponse serializeErrorResult
|
|
270
|
+
catch { message }
|
|
271
|
+
console.error "POST /ddb/run error:", message
|
|
272
|
+
binaryResponse serializeErrorResult message or 'Unknown error'
|
|
276
273
|
|
|
277
274
|
# POST /ddb/interrupt — Cancel running query
|
|
278
|
-
post '/ddb/interrupt'
|
|
275
|
+
post '/ddb/interrupt' ->
|
|
279
276
|
# In a real implementation, this would cancel the running query
|
|
280
277
|
# For now, just return empty result
|
|
281
278
|
binaryResponse serializeEmptyResult()
|
|
282
279
|
|
|
283
280
|
# POST /ddb/tokenize — Tokenize SQL for syntax highlighting
|
|
284
|
-
post '/ddb/tokenize'
|
|
285
|
-
sql =
|
|
281
|
+
post '/ddb/tokenize' ->
|
|
282
|
+
sql = read 'body', 'string' or ''
|
|
286
283
|
tokens = tokenizeSQL sql
|
|
287
284
|
binaryResponse serializeTokenizeResult tokens
|
|
288
285
|
|
|
289
286
|
# GET /info — Server version info (DuckDB UI checks this)
|
|
290
|
-
get '/info'
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
287
|
+
get '/info' ->
|
|
288
|
+
@body '', 200,
|
|
289
|
+
'Access-Control-Allow-Origin': '*'
|
|
290
|
+
'X-DuckDB-Version': '1.2.1'
|
|
291
|
+
'X-DuckDB-Platform': 'rip-db'
|
|
292
|
+
'X-DuckDB-UI-Extension-Version': VERSION
|
|
296
293
|
|
|
297
294
|
# Helper to create binary response
|
|
298
295
|
binaryResponse = (buffer) ->
|