Skip to content

Commit 1a87ade

Browse files
authored
Merge pull request #84 from malthe/docs
Add code-based documentation via TSDoc annotations
2 parents bc81a7f + 079579e commit 1a87ade

File tree

10 files changed

+287
-20
lines changed

10 files changed

+287
-20
lines changed

.github/workflows/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
env:
1212
PGDATADIR: /var/lib/postgresql/data
1313

14+
permissions:
15+
contents: read
16+
pages: write
17+
id-token: write
18+
1419
jobs:
1520
build:
1621
runs-on: ubuntu-latest
@@ -73,3 +78,18 @@ jobs:
7378
PGPORT: ${{ job.services.postgres.ports[5432] }}
7479
PGUSER: postgres
7580
PGPASSWORD: postgres
81+
- name: Docs
82+
run: npx typedoc
83+
- uses: actions/upload-pages-artifact@v2
84+
with:
85+
path: ./docs
86+
deploy:
87+
runs-on: ubuntu-latest
88+
environment:
89+
name: github-pages
90+
url: ${{ steps.deployment.outputs.page_url }}
91+
needs: build
92+
steps:
93+
- name: Deploy to GitHub Pages
94+
id: deployment
95+
uses: actions/deploy-pages@v2

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# ts-postgres
2-
31
![Build Status](https://github.com/malthe/ts-postgres/actions/workflows/main.yml/badge.svg)
42
<span class="badge-npmversion"><a href="https://npmjs.org/package/ts-postgres" title="View this project on NPM"><img src="https://img.shields.io/npm/v/ts-postgres.svg" alt="NPM version" /></a></span>
53
<span class="badge-npmdownloads"><a href="https://npmjs.org/package/ts-postgres" title="View this project on NPM"><img src="https://img.shields.io/npm/dm/ts-postgres.svg" alt="NPM downloads" /></a></span>
@@ -26,6 +24,8 @@ $ npm install ts-postgres@latest
2624
* Promise-based
2725
* Streaming
2826

27+
See the [documentation](https://malthe.github.io/ts-postgres/) for a complete reference.
28+
2929
---
3030

3131
## Usage
@@ -59,7 +59,7 @@ async function main() {
5959
}
6060
}
6161

62-
await main()
62+
await main();
6363
```
6464
Waiting on the result (i.e., result iterator) returns the complete query result.
6565

package-lock.json

Lines changed: 180 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@
7474
"eslint-config-standard": "^17.1.0",
7575
"eslint-plugin-import": "^2.29.0",
7676
"eslint-plugin-node": "^11.1.0",
77-
"eslint-plugin-promise": "^6.1.1",
7877
"eslint-plugin-prettier": "^5.0.1",
78+
"eslint-plugin-promise": "^6.1.1",
7979
"jest": "^29.7.0",
8080
"lint-staged": "^15.0.2",
8181
"rimraf": "^3.0.2",
8282
"ts-jest": "^29.1.1",
8383
"ts-node": "^10.9.1",
84+
"typedoc": "^0.25.4",
8485
"typescript": "^4.9.5"
8586
}
8687
}

src/client.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export interface PreparedStatement<T = ResultRecord> {
101101
) => ResultIterator<T>
102102
}
103103

104-
type Callback<T> = (data: T) => void;
104+
export type Callback<T> = (data: T) => void;
105105

106106
/* eslint-disable @typescript-eslint/no-explicit-any */
107107
type CallbackOf<U> = U extends any ? Callback<U> : never;
@@ -155,6 +155,11 @@ interface PreFlightQueue {
155155
bind: Bind | null;
156156
}
157157

158+
/** A database client, opening a single connection to the database.
159+
*
160+
* @remarks
161+
* You must open the connection using {@link connect}, otherwise no query will be processed.
162+
*/
158163
export class Client {
159164
private readonly events = {
160165
connect: new TypedEvent<Connect>(),
@@ -197,6 +202,11 @@ export class Client {
197202
public secretKey: number | null = null;
198203
public transactionStatus: TransactionStatus | null = null;
199204

205+
/**
206+
* @param config - An optional configuration object, comprised of connection details
207+
* and client configuration. Most of the connection details can also be specified
208+
* using environment variables, see {@link Environment}.
209+
*/
200210
constructor(public readonly config: Configuration = {}) {
201211
this.encoding = config.clientEncoding || defaults.clientEncoding as BufferEncoding || 'utf-8';
202212
this.writer = new Writer(this.encoding);

0 commit comments

Comments
 (0)