Skip to content

Commit 0820c5b

Browse files
Add bun run scripts
1 parent c4f06bf commit 0820c5b

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"typedoc": "rm -rf ./docs/ && typedoc --out docs && typedoc --plugin typedoc-plugin-markdown --out docs/markdown",
1717
"npmgui": "npx npm-gui@latest",
1818
"gateway-dev": "bun --watch ./src/gateway/gateway.ts",
19-
"gateway-test": "bun test ./src/gateway/connection-bun.test.ts --watch"
19+
"gateway-start": "bun --smol run ./src/gateway/gateway.ts",
20+
"gateway-test": "bun test ./src/gateway/connection-bun.test.ts --watch --coverage"
2021
},
2122
"repository": {
2223
"type": "git",

src/drivers/connection-tls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class SQLiteCloudTlsConnection extends SQLiteCloudConnection {
134134
// const startedOn = new Date()
135135

136136
// define what to do if an answer does not arrive within the set timeout
137-
let socketTimeout: number
137+
let socketTimeout: NodeJS.Timeout
138138

139139
// clear all listeners and call done in the operations queue
140140
const finish: ResultsCallback = (error, result) => {

src/drivers/connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export abstract class SQLiteCloudConnection {
1515
/** Parse and validate provided connectionString or configuration */
1616
constructor(config: SQLiteCloudConfig | string, callback?: ErrorCallback) {
1717
if (typeof config === 'string') {
18-
this.config = validateConfiguration({ connectionString: config })
18+
this.config = validateConfiguration({ connectionString: config })
1919
} else {
2020
this.config = validateConfiguration(config)
2121
}

src/gateway/connection-bun.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ describe('SQLiteCloudBunConnection', () => {
116116
const results = await sendCommands(chinookConnection, 'TEST BLOB')
117117
expect(typeof results).toBe('object')
118118
expect(results).toBeInstanceOf(Buffer)
119-
const bufferrowset = results as any as Buffer
119+
const bufferrowset = results as Buffer
120120
expect(bufferrowset.length).toBe(1000)
121121
})
122122

123123
test('should test blob0', async () => {
124124
const results = await sendCommands(chinookConnection, 'TEST BLOB0')
125125
expect(typeof results).toBe('object')
126126
expect(results).toBeInstanceOf(Buffer)
127-
const bufferrowset = results as any as Buffer
127+
const bufferrowset = results as Buffer
128128
expect(bufferrowset.length).toBe(0)
129129
})
130130

@@ -161,7 +161,7 @@ describe('SQLiteCloudBunConnection', () => {
161161
test('should test array', async () => {
162162
const results = await sendCommands(chinookConnection, 'TEST ARRAY')
163163
expect(Array.isArray(results)).toBe(true)
164-
const arrayrowset = results as any as Array<any>
164+
const arrayrowset = results as Array<any>
165165
expect(arrayrowset.length).toBe(5)
166166
expect(arrayrowset[0]).toBe('Hello World')
167167
expect(arrayrowset[1]).toBe(123456)

src/gateway/gateway.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ app.get('/v1/info', (req, res) => {
115115

116116
app.post('/v1/sql', async (req: express.Request, res: express.Response) => {
117117
try {
118-
log(`POST /v1/sql`)
118+
log('POST /v1/sql')
119119
const response = await handleHttpSqlRequest(req, res)
120120
res.json(response)
121121
} catch (error) {
@@ -168,11 +168,11 @@ async function handleHttpSqlRequest(request: express.Request, response: express.
168168

169169
/** Server info for /v1/info endpoints */
170170
function getServerInfo() {
171-
const { objectTypeCounts, ...memory } = heapStats()
171+
const { objectTypeCounts, protectedObjectTypeCounts, ...memory } = heapStats()
172172

173173
return {
174174
data: {
175-
name: packageJson.name,
175+
name: '@sqlitecloud/gateway',
176176
version: packageJson.version,
177177
date: new Date().toISOString(),
178178
memory
@@ -238,7 +238,7 @@ async function queryAsync(connection: SQLiteCloudBunConnection, apiRequest: SqlA
238238
result = await sendCommandsAsync(connection, apiRequest.sql)
239239
// query returned a rowset?
240240
if (result instanceof SQLiteCloudRowset) {
241-
const rowset = result as SQLiteCloudRowset
241+
const rowset = result
242242
const data = apiRequest.row === 'dictionary' ? rowset : rowset.map(rowsetRow => rowsetRow.getData()) // rows as arrays by default
243243
return { data, metadata: rowset.metadata }
244244
}

0 commit comments

Comments
 (0)