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
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ jobs:
matrix:
node-version: [12.x, 14.x, 16.x]
mongodb-version: ['4.0', '4.2', '4.4']
# these should match the minimum peerDependencies definitions
mongodb-types: ['3.6.20', '^3.6.20']
mongodb-lib: ['3.6.7', '^3.6.7']
mongodb-lib: ['4.3.1', '^4.3.1']

env:
NODE: ${{ matrix.node-version }}
Expand All @@ -56,7 +54,6 @@ jobs:
- run: yarn install --frozen-lockfile

# peerDeps installs
- run: yarn add -D @types/mongodb@${{matrix.mongodb-types}}
- run: yarn add -D mongodb@${{matrix.mongodb-lib}}

- run: yarn test --coverage
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"test": "jest"
},
"peerDependencies": {
"@types/mongodb": "^3.6.20",
"mongodb": "^3.6.7"
"mongodb": "^4.3.1"
},
"peerDependenciesMeta": {
"@types/mongodb": {
Expand All @@ -40,7 +39,7 @@
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.1.3",
"@types/jest": "^27.4.0",
"@types/mongodb": "^3.6.20",
"@types/mongodb": "^4.0.7",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"builtin-modules": "^3.2.0",
Expand All @@ -51,7 +50,7 @@
"husky": "^7.0.4",
"jest": "^27.4.7",
"lint-staged": "^12.1.7",
"mongodb": "^3.6.7",
"mongodb": "^4.3.1",
"prettier": "^2.5.1",
"rollup": "^2.64.0",
"standard-version": "^9.3.2",
Expand Down
7 changes: 3 additions & 4 deletions src/mongodb-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
*/

import crypto from 'crypto';
import type { Db, FilterQuery, ObjectId, UpdateQuery } from 'mongodb';
import type { Db, Filter, UpdateFilter } from 'mongodb';

// some helper functions
function id() {
return crypto.randomBytes(16).toString('hex');
}

type MessageSchema = {
_id: ObjectId;
createdAt: Date;
updatedAt?: Date;
visible: Date;
Expand Down Expand Up @@ -104,7 +103,7 @@ class MongoDbQueueImpl<T = unknown> implements MongoDbQueue {
return result.insertedId.toHexString();
}

let filter: FilterQuery<MessageSchema> = {
let filter: Filter<MessageSchema> = {
payload: { $eq: hashKey },
};

Expand Down Expand Up @@ -144,7 +143,7 @@ class MongoDbQueueImpl<T = unknown> implements MongoDbQueue {
deleted: null,
visible: { $lte: new Date(now) },
};
const update: UpdateQuery<MessageSchema> = {
const update: UpdateFilter<MessageSchema> = {
$inc: { tries: 1 },
$set: {
updatedAt: new Date(now),
Expand Down
6 changes: 1 addition & 5 deletions src/specs/__helpers__/setup-mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ class SetupMongo {
private _dbName: string;

get client() {
if (!this._client.isConnected()) {
throw new Error('Please wait for `connection()` on `beforeAll` hook');
}

return this._client;
}

Expand All @@ -17,7 +13,7 @@ class SetupMongo {
}

constructor(url: string, dbName: string) {
this._client = new MongoClient(url, { useUnifiedTopology: true });
this._client = new MongoClient(url);
this._dbName = dbName;
}

Expand Down
Loading