Skip to content

Commit 42cc373

Browse files
committed
chore: add documentation
1 parent 401163c commit 42cc373

File tree

2 files changed

+88
-5
lines changed

2 files changed

+88
-5
lines changed

packages/mongodb-runner/src/mongocluster.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,114 @@ import { EventEmitter } from 'events';
2424
import assert from 'assert';
2525
import { handleTLSClientKeyOptions } from './tls-helpers';
2626

27+
/**
28+
* Description of a MongoDB user account that will be created in a test cluster.
29+
*/
2730
export interface MongoDBUserDoc {
31+
/**
32+
* SCRAM-SHA-256 username.
33+
*/
2834
username: string;
35+
/**
36+
* SCRAM-SHA-256 password.
37+
*/
2938
password: string;
39+
/**
40+
* Additional metadata for a given user.
41+
*/
3042
customData?: Document;
43+
/**
44+
* Roles to assign to the user.
45+
*/
3146
roles: ({ role: string; db?: string } | string)[];
47+
/**
48+
* Additional fields may be included as per the `createUser` command.
49+
*/
50+
[key: string]: unknown;
3251
}
3352

53+
/** Describe the individual members of a replica set */
3454
export interface RSMemberOptions {
55+
/**
56+
* Tags to assign to the member, in the format expected by the Node.js driver.
57+
*/
3558
tags?: TagSet;
59+
/**
60+
* Priority of the member. If none is specified, one member will be given priority 1
61+
* and all others priority 0. The mongodb-runner package assumes that the highest priority
62+
* member will become primary.
63+
*/
3664
priority?: number;
65+
/**
66+
* Additional arguments for the member.
67+
*/
3768
args?: string[];
69+
/**
70+
* Whether the member is an arbiter.
71+
*/
3872
arbiterOnly?: boolean;
3973
}
4074

75+
/**
76+
* Shared options for all cluster topologies.
77+
*/
4178
export interface CommonOptions {
79+
/**
80+
* Directory where server binaries will be downloaded and stored.
81+
*/
4282
downloadDir?: string;
83+
/**
84+
* Various options to control the download of MongoDB binaries.
85+
*/
4386
downloadOptions?: DownloadOptions;
4487

88+
/**
89+
* OIDC mock provider command line (e.g. '--port=0' or full path to binary).
90+
* If provided, an OIDC mock provider will be started alongside the cluster,
91+
* and the necessary parameters to connect to it will be added to the
92+
* cluster's mongod/mongos processes.
93+
*/
4594
oidc?: string;
4695

96+
/**
97+
* MongoDB server version to download and use (e.g. '6.0.3', '8.x-enterprise', 'latest-alpha', etc.)
98+
*/
4799
version?: string;
100+
/**
101+
* User accounts to create after starting the cluster.
102+
*/
48103
users?: MongoDBUserDoc[];
104+
105+
/**
106+
* Whether to automatically add an additional TLS client certificate key file
107+
* to the cluster nodes based on whether TLS configuration was detected.
108+
*
109+
* Adding this is required in order for authentication to work when TLS is enabled.
110+
*/
49111
tlsAddClientKey?: boolean;
50112

113+
/**
114+
* Topology of the cluster.
115+
*/
51116
topology: 'standalone' | 'replset' | 'sharded';
52117
}
53118

119+
/**
120+
* Options specific to replica set clusters.
121+
*/
54122
export type RSOptions = {
123+
/** Number of arbiters to create (default: 0) */
55124
arbiters?: number;
125+
/** Number of secondary nodes to create (default: 2) */
56126
secondaries?: number;
127+
/** Explicitly specify replica set members. If set, `arbiters` and `secondaries` will be ignored. */
57128
rsMembers?: RSMemberOptions[];
58129
};
59130

60131
export type ShardedOptions = {
132+
/** Arguments to pass to each mongos instance. */
61133
mongosArgs?: string[][];
134+
/** Number of shards to create or explicit shard configurations. */
62135
shards?: number | Partial<MongoClusterOptions>[];
63136
};
64137

packages/mongodb-runner/src/mongoserver.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,23 @@ import {
2222
makeConnectionString,
2323
} from './util';
2424

25+
/**
26+
* Options for starting a MongoDB server process.
27+
*/
2528
export interface MongoServerOptions {
29+
/** Directory where server binaries are located. */
2630
binDir?: string;
27-
binary: string; // 'mongod', 'mongos', etc.
28-
tmpDir: string; // Stores e.g. database contents
29-
logDir?: string; // If set, pipe log file output through here.
30-
args?: string[]; // May or may not contain --port
31-
docker?: string | string[]; // Image or docker options
31+
/** The MongoDB binary to run, e.g., 'mongod', 'mongos', etc. */
32+
binary: string;
33+
/** Directory for temporary files, e.g., database contents */
34+
tmpDir: string;
35+
/** If set, log file output will be piped through here. */
36+
logDir?: string;
37+
/** Arguments to pass to the MongoDB binary. May or may not contain --port */
38+
args?: string[];
39+
/** Docker image or options to run the MongoDB binary in a container. */
40+
docker?: string | string[];
41+
/** Internal options for the MongoDB client used by this server instance. */
3242
internalClientOptions?: Partial<MongoClientOptions>;
3343
}
3444

0 commit comments

Comments
 (0)