@rip-lang/db 0.8.5 → 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.
Files changed (2) hide show
  1. package/db.rip +20 -23
  2. 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().body
160
- console.log "POST /", sql
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', (req) ->
241
+ post '/ddb/run' ->
243
242
  try
244
- sql = req.text!
245
- console.log "POST /ddb/run", sql?.slice?(0, 100) or sql
243
+ sql = read 'body', 'string'
244
+ return binaryResponse serializeErrorResult 'Empty query' unless sql
246
245
 
247
- return binaryResponse serializeErrorResult 'Empty query' unless sql?.trim()
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 error
274
- console.error "POST /ddb/run error:", error.message
275
- binaryResponse serializeErrorResult error.message or String(error)
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', (req) ->
285
- sql = req.text! or ''
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', (req, res) ->
291
- res.headers.set 'Access-Control-Allow-Origin', '*'
292
- res.headers.set 'X-DuckDB-Version', '1.2.1' # Pretend to be DuckDB
293
- res.headers.set 'X-DuckDB-Platform', 'rip-db'
294
- res.headers.set 'X-DuckDB-UI-Extension-Version', VERSION
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) ->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/db",
3
- "version": "0.8.5",
3
+ "version": "0.9.0",
4
4
  "description": "DuckDB Server — Simple HTTP API for DuckDB queries",
5
5
  "type": "module",
6
6
  "main": "db.rip",