Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for mongodb@6 #1

Merged
merged 36 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e1edcae
Add support for `mongodb@6`
sebamarynissen Jan 31, 2024
52b99f6
Use promise for `toArray()`
sebamarynissen Jan 31, 2024
937be77
Make `mongodb@6` the default
sebamarynissen Jan 31, 2024
9783325
Use various mongodb clients in tests
sebamarynissen Jan 31, 2024
a9ac53c
Fix flakey tests
sebamarynissen Jan 31, 2024
2bb883f
Restore setting up mongo on GitHub actions
sebamarynissen Jan 31, 2024
84bf56a
Run tests with various mongo versions
sebamarynissen Jan 31, 2024
6617943
Update test.yml
sebamarynissen Jan 31, 2024
df75618
Update README.md
sebamarynissen Jan 31, 2024
61340ca
Update package.json
sebamarynissen Jan 31, 2024
5f7a012
Update .gitignore
sebamarynissen Jan 31, 2024
9bc27b6
Add publish to npm workflow
sebamarynissen Jan 31, 2024
ff51fea
Update test.yml
sebamarynissen Jan 31, 2024
89f8f55
Run eslint fix
sebamarynissen Jan 31, 2024
df1bd10
Fix linting errors
sebamarynissen Jan 31, 2024
35de37a
Run less tests
sebamarynissen Jan 31, 2024
b7fcc0e
Delete docs.yml
sebamarynissen Jan 31, 2024
651dc93
Run tests for 5 and 6 again
sebamarynissen Jan 31, 2024
98a6eca
Update test.yml
sebamarynissen Jan 31, 2024
b977212
Make mongodb a peer dependency
sebamarynissen Jan 31, 2024
a441cb9
Gtfo TypeScript
sebamarynissen Jan 31, 2024
495fdf3
Add mongodb as peer dependency
sebamarynissen Jan 31, 2024
308c7ce
Require mongodb for development
sebamarynissen Jan 31, 2024
b240f8f
End the TypeScript madness plz
sebamarynissen Jan 31, 2024
ecfd5b6
Revert "End the TypeScript madness plz"
sebamarynissen Jan 31, 2024
d2bb446
Update test.yml
sebamarynissen Jan 31, 2024
bc11d10
Limit tests for `mongodb@6`
sebamarynissen Jan 31, 2024
d686a8a
Update README.md
sebamarynissen Jan 31, 2024
74f0127
Output native esm
sebamarynissen Jan 31, 2024
0d10c68
Fix tests for esm output
sebamarynissen Jan 31, 2024
206f332
Set TypeScript target to es2022 again
sebamarynissen Jan 31, 2024
d743a72
Don't rely on `import.meta.dirname`
sebamarynissen Jan 31, 2024
08bde7d
Fix linting errors
sebamarynissen Jan 31, 2024
c128f41
Update README.md
sebamarynissen Jan 31, 2024
c7a8aa3
Update README.md
sebamarynissen Jan 31, 2024
6cc0685
Update README.md
sebamarynissen Jan 31, 2024
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
6 changes: 6 additions & 0 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ module.exports = {
project: './tsconfig.eslint.json'
},
overrides: [
{
files: ['*ts'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
},
},
{
files: ['*.test.ts'],
env: {
Expand Down
32 changes: 0 additions & 32 deletions .github/workflows/docs.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Node.js package

on:
release:
types: [created]

jobs:
publish-npm:
name: Publish to npm
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: npm
- run: npm version ${TAG_NAME} --git-tag-version=false
env:
TAG_NAME: ${{ github.event.release.tag_name }}
- run: npm whoami; npm --ignore-scripts publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
21 changes: 9 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: Run Test
name: Run tests
on: [push, pull_request, workflow_dispatch]

jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14, 16, 18]
mongodb-version: [3.6, 4.4, 5.0]
node-version: [18, 20, 21]
mongodb-version: [6.0, 7.0]
steps:
- name: Git checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -23,7 +23,7 @@ jobs:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Cache node modules
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand All @@ -33,11 +33,8 @@ jobs:
restore-keys: |
${{ runner.os }}-build-agenda-

- name: Update npm
run: npm -g install npm@latest

- name: Install Packages
run: npm install
run: npm ci

- name: Run Lint
run: npm run lint
Expand All @@ -48,6 +45,6 @@ jobs:
CI: true

- name: Test
run: npm run test
run: npm test
env:
CI: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ docs/agenda/*
dist
.nyc_output
coverage
*.tsbuildinfo
2 changes: 1 addition & 1 deletion .mocharc.jsonc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"diff": true,
"spec": "./test/*.test.ts",
"require": ["ts-node/register", "source-map-support/register"],
"import": ["tsx/esm"],
"extension": ["js", "ts"],
"package": "./package.json",
"recursive": true,
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# AgendaTS
**DISCLAIMER**: I **do not** intend to actively maintain this repository.
I forked it from https://github.com/hokify/agenda because I desperately needed support for [mongodb@6](https://www.npmjs.com/package/mongodb) for my website www.whisthub.com.
Ideally this gets merged back eventually into [@hokify/agenda](https://github.com/hokify/agenda), or even better in [agenda/agenda](https://github.com/agenda/agenda).

(full typed version of agendaJS)
However, I *do* intend to keep this up to date with the latest version of the [mongodb](https://www.npmjs.com/package/mongodb) package, but that's all.
Agenda is a great library and I would hate to see it dying because new mongodb versions are not supported.

Key differences with the [original repo](https://github.com/hokify/agenda) are:

- MongoDB is now a peer dependency, so it must be installed separately.
- The module is now [esm only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). This is to prepare for any of the dependencies - most notably `mongodb` - becoming esm-only one day too. It also helps push the ecosystem forward.
- The library is only tested against `mongodb@6`, but it should work for version 5 and even 4.

# Agenda

<p align="center">
<img src="https://cdn.jsdelivr.net/gh/hokify/agenda@master/agendats.png" alt="Agenda TS" width="100" height="100">
Expand All @@ -13,7 +24,7 @@ This was originally a fork of agenda.js,
it differs from the original version in following points:

- Complete rewrite in Typescript (fully typed!)
- mongodb4 driver (supports mongodb 5.x)
- [mongodb@6](https://www.npmjs.com/package/mongodb) driver (supports mongodb 5.x and mongodb 4.x too)
- Supports mongoDB sharding by name
- touch() can have an optional progress parameter (0-100)
- Bugfixes and improvements for locking & job processing (concurrency, lockLimit,..)
Expand Down
Loading