Skip to content

Commit 290e57d

Browse files
committed
docs(README): add missing "auth" object documentation
1 parent 6ce12bf commit 290e57d

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

README.md

+25-3
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ All options are optional.
117117

118118
```js
119119
const mongod = new MongoMemoryServer({
120-
instance: {
120+
instance?: {
121121
port?: number, // by default choose any free port
122122
ip?: string, // by default '127.0.0.1', for binding to all IP addresses set it to `::,0.0.0.0`,
123123
dbName?: string, // by default '' (empty string)
@@ -127,14 +127,36 @@ const mongod = new MongoMemoryServer({
127127
auth?: boolean, // by default `mongod` is started with '--noauth', start `mongod` with '--auth'
128128
args?: string[], // by default no additional arguments, any additional command line arguments for `mongod` `mongod` (ex. ['--notablescan'])
129129
},
130-
binary: {
130+
binary?: {
131131
version?: string, // by default '5.0.19'
132132
downloadDir?: string, // see the documentation on what is chosen by default https://nodkz.github.io/mongodb-memory-server/docs/api/config-options#download_dir
133133
platform?: string, // by default os.platform()
134134
arch?: string, // by default os.arch()
135135
checkMD5?: boolean, // by default false OR process.env.MONGOMS_MD5_CHECK
136136
systemBinary?: string, // by default undefined or process.env.MONGOMS_SYSTEM_BINARY
137137
},
138+
// using "auth" will manage "instance.auth"
139+
auth?: {
140+
disable?: boolean, // disable automatic auth creation
141+
customRootName?: string, // by default "mongodb-memory-server-root"
142+
customRootPwd?: string, // by default "rootuser"
143+
force?: boolean, // force creation of users
144+
keyfileContent?: string, // by default "0123456789"
145+
extraUsers?: [{
146+
// see mongodb documentation https://docs.mongodb.com/manual/reference/method/db.createUser/#definition)
147+
createUser: string, // user name
148+
pwd: string, // user password
149+
roles: UserRoles[], // user roles
150+
database?: string, // which database the user is created on
151+
customData?: Record<string, any>,
152+
mechanisms?: ('SCRAM-SHA-1' | 'SCRAM-SHA-256')[],
153+
authenticationRestrictions?: {
154+
clientSource?: string;
155+
serverAddress?: string;
156+
}[],
157+
digestPassword?: boolean,
158+
}],
159+
},
138160
});
139161
```
140162

@@ -173,7 +195,7 @@ const replSet = new MongoMemoryReplSet({
173195
// unless otherwise noted below these values will be in common with all instances spawned:
174196
replSet: {
175197
name, // replica set name (default: 'testset')
176-
auth, // enable auth support? (default: false)
198+
auth?: boolean | AutomaticAuth, // enable auth, for options see #available-options-for-mongomemoryserver
177199
args, // any args specified here will be combined with any per instance args from `instanceOpts`
178200
count, // number of additional `mongod` processes to start (will not start any extra if instanceOpts.length > replSet.count); (default: 1)
179201
dbName, // default database for db URI strings. (default: uuid.v4())

0 commit comments

Comments
 (0)