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
31 changes: 19 additions & 12 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions packages/wabe-mongodb-launcher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wabe-mongodb-launcher",
"version": "0.5.2",
"version": "0.5.3",
"description": "Package to launch the mongodb for test",
"license": "Apache-2.0",
"files": [
Expand All @@ -14,8 +14,7 @@
"format": "oxfmt --write ."
},
"dependencies": {
"mongodb-memory-server": "10.1.4",
"p-queue": "8.1.0",
"mongodb-memory-server": "11.0.1",
"tcp-port-used": "1.0.2"
},
"devDependencies": {
Expand Down
24 changes: 14 additions & 10 deletions packages/wabe-mongodb-launcher/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import { MongoMemoryServer } from 'mongodb-memory-server'
import tcpPortUsed from 'tcp-port-used'
import PQueue from 'p-queue'

const queue = new PQueue({ concurrency: 1 })
type RunDatabaseOptions = {
binaryVersion?: string
}

export const runDatabase = async (): Promise<void> =>
queue.add(async () => {
await startMongo()
})
export const runDatabase = async (
port: number = 27045,
options: RunDatabaseOptions = {},
): Promise<void> => startMongo(port, options)

const startMongo = async (): Promise<void> => {
if (await tcpPortUsed.check(27045, '127.0.0.1')) return
const startMongo = async (
port: number,
{ binaryVersion = '8.2.1' }: RunDatabaseOptions = {},
): Promise<void> => {
if (await tcpPortUsed.check(port, '127.0.0.1')) return

await MongoMemoryServer.create({
binary: {
version: '8.0.5',
version: binaryVersion,
},
instance: {
port: 27045,
port,
},
})

Expand Down