Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dist
/.eslintcache
.vscode/
manually-test-on-heroku.js
**/.*nyc_output/
2 changes: 1 addition & 1 deletion docs/pages/apis/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Config = {
host?: string, // default process.env.PGHOST
port?: number, // default process.env.PGPORT
database?: string, // default process.env.PGDATABASE || user
connectionString?: string, // e.g. postgres://user:password@host:5432/database
connectionString?: string, // e.g. gaussdb://user:password@host:5432/database
ssl?: any, // passed directly to node.TLSSocket, supports all tls.connect options
types?: any, // custom type parsers
statement_timeout?: number, // number of milliseconds before a statement in query will time out, default is no timeout
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/features/ssl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ If you plan to use a combination of a database connection string from the enviro

```js
const config = {
connectionString: 'postgres://user:password@host:port/db?sslmode=require',
connectionString: 'gaussdb://user:password@host:port/db?sslmode=require',
// Beware! The ssl object is overwritten when parsing the connectionString
ssl: {
rejectUnauthorized: false,
Expand Down

This file was deleted.

8 changes: 4 additions & 4 deletions packages/gaussdb-connection-string/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MIT License
```js
const parse = require('pg-connection-string').parse;

const config = parse('postgres://someuser:somepassword@somehost:381/somedatabase')
const config = parse('gaussdb://someuser:somepassword@somehost:381/somedatabase')
```

The resulting config contains a subset of the following properties:
Expand All @@ -40,7 +40,7 @@ The pg-connection-string `ConnectionOptions` interface is not compatible with th
import { ClientConfig } from 'pg';
import { parseIntoClientConfig } from 'pg-connection-string';

const config: ClientConfig = parseIntoClientConfig('postgres://someuser:somepassword@somehost:381/somedatabase')
const config: ClientConfig = parseIntoClientConfig('gaussdb://someuser:somepassword@somehost:381/somedatabase')
```

You can also use `toClientConfig` to convert an existing `ConnectionOptions` interface into a `ClientConfig` interface:
Expand All @@ -49,7 +49,7 @@ You can also use `toClientConfig` to convert an existing `ConnectionOptions` int
import { ClientConfig } from 'pg';
import { parse, toClientConfig } from 'pg-connection-string';

const config = parse('postgres://someuser:somepassword@somehost:381/somedatabase')
const config = parse('gaussdb://someuser:somepassword@somehost:381/somedatabase')
const clientConfig: ClientConfig = toClientConfig(config)
```

Expand All @@ -58,7 +58,7 @@ const clientConfig: ClientConfig = toClientConfig(config)
The short summary of acceptable URLs is:

* `socket:<path>?<query>` - UNIX domain socket
* `postgres://<user>:<password>@<host>:<port>/<database>?<query>` - TCP connection
* `gaussdb://<user>:<password>@<host>:<port>/<database>?<query>` - TCP connection

But see below for more details.

Expand Down
4 changes: 2 additions & 2 deletions packages/gaussdb-connection-string/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ function parse(str, options = {}) {
}

try {
result = new URL(str, 'postgres://base')
result = new URL(str, 'gaussdb://base')
} catch (e) {
// The URL is invalid so try again with a dummy host
result = new URL(str.replace('@/', '@___DUMMY___/'), 'postgres://base')
result = new URL(str.replace('@/', '@___DUMMY___/'), 'gaussdb://base')
dummyHost = true
}

Expand Down
22 changes: 11 additions & 11 deletions packages/gaussdb-connection-string/test/clientConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { parse, toClientConfig, parseIntoClientConfig } from '../'

describe('toClientConfig', function () {
it('converts connection info', function () {
const config = parse('postgres://brian:pw@boom:381/lala')
const config = parse('gaussdb://brian:pw@boom:381/lala')
const clientConfig = toClientConfig(config)

clientConfig.user?.should.equal('brian')
Expand All @@ -18,7 +18,7 @@ describe('toClientConfig', function () {

it('converts query params', function () {
const config = parse(
'postgres:///?application_name=TheApp&fallback_application_name=TheAppFallback&client_encoding=utf8&options=-c geqo=off'
'gaussdb:///?application_name=TheApp&fallback_application_name=TheAppFallback&client_encoding=utf8&options=-c geqo=off'
)
const clientConfig = toClientConfig(config)

Expand All @@ -29,21 +29,21 @@ describe('toClientConfig', function () {
})

it('converts SSL boolean', function () {
const config = parse('pg:///?ssl=true')
const config = parse('gaussdb:///?ssl=true')
const clientConfig = toClientConfig(config)

clientConfig.ssl?.should.equal(true)
})

it('converts sslmode=disable', function () {
const config = parse('pg:///?sslmode=disable')
const config = parse('gaussdb:///?sslmode=disable')
const clientConfig = toClientConfig(config)

clientConfig.ssl?.should.equal(false)
})

it('converts sslmode=noverify', function () {
const config = parse('pg:///?sslmode=no-verify')
const config = parse('gaussdb:///?sslmode=no-verify')
const clientConfig = toClientConfig(config)

clientConfig.ssl?.should.deep.equal({
Expand All @@ -52,22 +52,22 @@ describe('toClientConfig', function () {
})

it('converts other sslmode options', function () {
const config = parse('pg:///?sslmode=verify-ca')
const config = parse('gaussdb:///?sslmode=verify-ca')
const clientConfig = toClientConfig(config)

clientConfig.ssl?.should.deep.equal({})
})

it('converts other sslmode options', function () {
const config = parse('pg:///?sslmode=verify-ca')
const config = parse('gaussdb:///?sslmode=verify-ca')
const clientConfig = toClientConfig(config)

clientConfig.ssl?.should.deep.equal({})
})

it('converts ssl cert options', function () {
const connectionString =
'pg:///?sslcert=' +
'gaussdb:///?sslcert=' +
__dirname +
'/example.cert&sslkey=' +
__dirname +
Expand All @@ -93,13 +93,13 @@ describe('toClientConfig', function () {
})

it('handles invalid port', function () {
const config = parse('postgres://@boom:381/lala')
const config = parse('gaussdb://@boom:381/lala')
config.port = 'bogus'
expect(() => toClientConfig(config)).to.throw()
})

it('handles invalid sslconfig values', function () {
const config = parse('postgres://@boom/lala')
const config = parse('gaussdb://@boom/lala')
config.ssl = {}
config.ssl.cert = null
config.ssl.key = undefined
Expand All @@ -114,7 +114,7 @@ describe('toClientConfig', function () {

describe('parseIntoClientConfig', function () {
it('converts url', function () {
const clientConfig = parseIntoClientConfig('postgres://brian:pw@boom:381/lala')
const clientConfig = parseIntoClientConfig('gaussdb://brian:pw@boom:381/lala')

clientConfig.user?.should.equal('brian')
clientConfig.password?.should.equal('pw')
Expand Down
Loading