Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Dliu/pg browser #2

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bc922a2
Changes for websockets and cursors
daniel-liu-bitio Feb 22, 2022
86558d2
Add pg browser
daniel-liu-bitio Feb 28, 2022
a8d4e8f
Clean up webpack config file
daniel-liu-bitio Feb 28, 2022
b22bd76
Merge branch 'master' into dliu/pg-browser
daniel-liu-bitio Feb 28, 2022
5346973
Fix yarn.lock
daniel-liu-bitio Feb 28, 2022
ab56adf
Modify pg tests
daniel-liu-bitio Mar 1, 2022
e0506b7
Update packages/pg-cursor/index.js
daniel-liu-bitio Mar 1, 2022
096c823
Comment clarifications
daniel-liu-bitio Mar 1, 2022
7fae74e
Remove yarn.loc
daniel-liu-bitio Mar 1, 2022
aa6fcf4
Fix pg test defaults and comment clarifications
daniel-liu-bitio Mar 1, 2022
e3adc69
Update packages/pg-cursor/index.js
daniel-liu-bitio Mar 2, 2022
db91f5b
Merge branch 'dliu/pg-browser' of https://github.com/daniel-liu-bitio…
daniel-liu-bitio Mar 2, 2022
70880de
Add comment to connection.end
daniel-liu-bitio Mar 2, 2022
7b6c17b
Add back original IP/hostname functionality
daniel-liu-bitio Mar 2, 2022
ff56d38
Add 130-tests.js back into test suite
daniel-liu-bitio Mar 2, 2022
42e05cc
Restore original integration/connection/test-helper
daniel-liu-bitio Mar 2, 2022
b58ec5c
Change some devDependencies back to dependencies
daniel-liu-bitio Mar 2, 2022
62dde3f
Remove status message logging
daniel-liu-bitio Mar 3, 2022
b55e00d
Fix stream placeholder logic
daniel-liu-bitio Mar 3, 2022
8462ab8
Send closing code + status on connection end
daniel-liu-bitio Mar 7, 2022
2f4a80d
Remove commented out original tests
daniel-liu-bitio Mar 9, 2022
f05b81c
Add simple performance test file
daniel-liu-bitio Mar 14, 2022
b7eae9d
Add cursor -> select example
daniel-liu-bitio Mar 14, 2022
d622ec7
Add yarn.lock
daniel-liu-bitio Mar 14, 2022
7b10504
Add messages.d.ts
daniel-liu-bitio Mar 14, 2022
e915f5d
recent
daniel-liu-bitio Mar 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"eslint-plugin-prettier": "^3.1.4",
"lerna": "^4.0.0",
"prettier": "2.1.2",
"typescript": "^4.0.3"
"typescript": "^4.0.3",
"webpack-cli": "^4.9.2"
},
"prettier": {
"semi": false,
Expand Down
3 changes: 1 addition & 2 deletions packages/pg/lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Connection extends EventEmitter {
if(port && host) {
var url = 'ws://'+host+':'+port;
} else {
var url = 'ws://localhost:5901'
var url = 'ws://localhost:5432'
}
this.stream = new WebSocketStream(url)
this.placeholderStream = false
Expand Down Expand Up @@ -131,7 +131,6 @@ class Connection extends EventEmitter {
this.emit('message', msg)
}
this.emit(eventName, msg)
// console.log(msg)
})
}

Expand Down
9 changes: 3 additions & 6 deletions packages/pg/lib/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,20 @@ module.exports = {

// database user's name
user: process.platform === 'win32' ? process.env.USERNAME : process.env.USER,
// user: 'postgres',

// name of database to connect
// database: undefined,
database: 'postgres',
database: undefined,

// database user's password
// password: null,
password: 'password',
password: null,

// a Postgres connection string to be used instead of setting individual connection items
// NOTE: Setting this value will cause it to override any other value (such as database or user) defined
// in the defaults object.
connectionString: undefined,

// database port
port: 5901,
port: 5432,

// number of rows to return at a time from a prepared statement's
// portal. 0 will return all rows at once
Expand Down
2 changes: 1 addition & 1 deletion packages/pg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-browser",
"version": "1.0.3",
"version": "1.0.5",
"description": "PostgreSQL with websockets",
"keywords": [
"database",
Expand Down
12 changes: 6 additions & 6 deletions packages/pg/test/integration/client/configuration-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ for (var key in process.env) {
suite.test('default values are used in new clients', function () {
assert.same(pg.defaults, {
user: process.env.USER,
database: 'postgres',
password: 'password',
port: 5901,
database: undefined,
password: null,
port: 5432,
rows: 0,
max: 10,
binary: false,
Expand All @@ -31,9 +31,9 @@ suite.test('default values are used in new clients', function () {
var client = new pg.Client()
assert.same(client, {
user: process.env.USER,
database: 'postgres',
password: 'password',
port: 5901,
database: process.env.USER,
password: null,
port: 5432,
})
})

Expand Down
2 changes: 1 addition & 1 deletion packages/pg/test/integration/connection/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var connect = function (callback) {
var username = helper.args.user
var database = helper.args.database
// var con = new Connection({ stream: new net.Stream() })
var con = new Connection({stream: new WebSocketStream('ws://localhost:5901')})
var con = new Connection({stream: new WebSocketStream('ws://localhost:5432')})
con.on('error', function (error) {
console.log(error)
throw new Error('Connection error')
Expand Down
1 change: 1 addition & 0 deletions packages/pg/test/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Test {
constructor(name, cb) {
this.name = name
this.action = cb
// timeout set higher since 1105-tests.js takes around 9000 ms to pass with websockets
this.timeout = 10000
}

Expand Down
10 changes: 5 additions & 5 deletions packages/pg/test/unit/client/configuration-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ require('./test-helper')
var assert = require('assert')

var pguser = process.env['PGUSER'] || process.env.USER
var pgdatabase = process.env['PGDATABASE'] || 'postgres'
var pgport = process.env['PGPORT'] || 5901
var pgdatabase = process.env['PGDATABASE'] || process.env.USER
var pgport = process.env['PGPORT'] || 5432

test('client settings', function () {
test('defaults', function () {
Expand Down Expand Up @@ -90,10 +90,10 @@ test('initializing from a config string', function () {
test('when not including all values the defaults are used', function () {
var client = new Client('postgres://host1')
assert.equal(client.user, process.env['PGUSER'] || process.env.USER)
assert.equal(client.password, process.env['PGPASSWORD'] || 'password')
assert.equal(client.password, process.env['PGPASSWORD'] || null)
assert.equal(client.host, 'host1')
assert.equal(client.port, process.env['PGPORT'] || 5901)
assert.equal(client.database, process.env['PGDATABASE'] || 'postgres')
assert.equal(client.port, process.env['PGPORT'] || 5432)
assert.equal(client.database, process.env['PGDATABASE'] || process.env.USER)
})

test('when not including all values the environment variables are used', function () {
Expand Down
28 changes: 14 additions & 14 deletions packages/pg/test/unit/connection/startup-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test('connection can take existing stream', function () {
assert.equal(con.stream, stream)
})

// test('using any stream', function () {
test('using any stream', function () {
// var makeStream = function () {
// var stream = new MemoryStream()

Expand All @@ -20,10 +20,10 @@ test('connection can take existing stream', function () {
// }

// var stream = makeStream()

// var con = new Connection({ stream: stream })
// con = new Client({connection: con})
// con.connect()
var stream = new MemoryStream()
var con = new Connection({ stream: stream })
con = new Client({connection: con})
con.connect()
// con.websocket.close()
// con.end()
// test('makes stream connect', function () {
Expand All @@ -38,16 +38,16 @@ test('connection can take existing stream', function () {
// assert.equal(stream.host, 'bang')
// })

// test('after stream connects client emits connected event', function () {
// var hit = false
test('after stream connects client emits connected event', function () {
var hit = false

// con.once('connect', function () {
// hit = true
// })
con.once('connect', function () {
hit = true
})

// assert.ok(stream.emit('connect'))
// assert.ok(hit)
// })
assert.ok(con.emit('connect'))
assert.ok(hit)
})

// TCP-keepalive not relevant for websockets

Expand All @@ -67,4 +67,4 @@ test('connection can take existing stream', function () {
// assert.equal(res, true)
// })
// })
// })
})
Loading