From 1d877478a2c1e815ba122fad3cebdb4c6c587232 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Aug 2021 04:11:17 +0000 Subject: [PATCH 01/20] Bump fastify/github-action-merge-dependabot from 2.3.0 to 2.4.0 (#107) Bumps [fastify/github-action-merge-dependabot](https://github.com/fastify/github-action-merge-dependabot) from 2.3.0 to 2.4.0. - [Release notes](https://github.com/fastify/github-action-merge-dependabot/releases) - [Commits](https://github.com/fastify/github-action-merge-dependabot/compare/v2.3.0...v2.4.0) --- updated-dependencies: - dependency-name: fastify/github-action-merge-dependabot dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 273ed32..dcc16fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,6 +78,6 @@ jobs: needs: test runs-on: ubuntu-latest steps: - - uses: fastify/github-action-merge-dependabot@v2.3.0 + - uses: fastify/github-action-merge-dependabot@v2.4.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} From cedc35ec3839cc3f2a5caba77840c91944d59a55 Mon Sep 17 00:00:00 2001 From: darkgl0w <31093081+darkgl0w@users.noreply.github.com> Date: Thu, 23 Sep 2021 12:27:53 +0200 Subject: [PATCH 02/20] chore: code cleanup (#110) * chore: upgrade package dependencies * chore: add a `lint:fix` command * test: add new test cases and make test names more explicit * refactor: improve code readability * chore: upgrade package dependencies * refactor (test): typo fix * refactor (test): apply @mcollina suggestion to use await fastify.ready() --- index.js | 28 ++++++------ package.json | 15 ++++--- test/add-handler.test.js | 13 +++--- test/initialization.test.js | 36 ++++++++++++++- test/req-initialization.test.js | 77 +++++++++++++++++++++++++-------- 5 files changed, 123 insertions(+), 46 deletions(-) diff --git a/index.js b/index.js index 9299108..d5cab2b 100644 --- a/index.js +++ b/index.js @@ -102,19 +102,21 @@ function fastifyPostgres (fastify, options, next) { if (db[name]) { return next(new Error(`fastify-postgres '${name}' is a reserved keyword`)) } else if (!fastify.pg) { - fastify.decorate('pg', {}) + fastify.decorate('pg', Object.create(null)) } else if (fastify.pg[name]) { return next(new Error(`fastify-postgres '${name}' instance name has already been registered`)) } fastify.pg[name] = db } else { - if (!fastify.pg) { - fastify.decorate('pg', db) - } else if (fastify.pg.pool) { - return next(new Error('fastify-postgres has already been registered')) - } else { + if (fastify.pg) { + if (fastify.pg.pool) { + return next(new Error('fastify-postgres has already been registered')) + } + Object.assign(fastify.pg, db) + } else { + fastify.decorate('pg', db) } } @@ -125,13 +127,11 @@ function fastifyPostgres (fastify, options, next) { fastify.addHook('onRoute', routeOptions => { const transact = routeOptions && routeOptions.pg && routeOptions.pg.transact - if (!transact) { - return - } - if (typeof transact === 'string' && transact !== name) { - return - } - if (name && transact === true) { + if ( + !transact || + (typeof transact === 'string' && transact !== name) || + (name && transact === true) + ) { return } @@ -140,7 +140,7 @@ function fastifyPostgres (fastify, options, next) { if (name) { if (!req.pg) { - req.pg = {} + req.pg = Object.create(null) } if (client[name]) { diff --git a/package.json b/package.json index 9ff49df..6231ec1 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "types": "index.d.ts", "scripts": { "check-examples": "tsc --build examples/typescript/*", + "lint:fix": "standard --fix", "load-data": "docker exec -it fastify-postgres psql -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U postgres -d postgres", "postgres": "docker run -p 5432:5432 --name fastify-postgres -e POSTGRES_PASSWORD=postgres -d postgres:11-alpine", "test": "standard && tap -J test/*.test.js && npm run test:typescript", @@ -36,15 +37,15 @@ "fastify-plugin": "^3.0.0" }, "devDependencies": { - "@tsconfig/node10": "^1.0.7", - "@types/pg": "^8.6.0", - "fastify": "^3.0.0", - "pg": "^8.2.1", + "@tsconfig/node10": "^1.0.8", + "@types/pg": "^8.6.1", + "fastify": "^3.21.5", + "pg": "^8.7.1", "pg-native": "^3.0.0", - "standard": "^16.0.0", - "tap": "^15.0.2", + "standard": "^16.0.3", + "tap": "^15.0.10", "tsd": "^0.17.0", - "typescript": "^4.0.2" + "typescript": "^4.4.3" }, "peerDependencies": { "pg": ">=6.0.0" diff --git a/test/add-handler.test.js b/test/add-handler.test.js index 1ae4eba..72ab91e 100644 --- a/test/add-handler.test.js +++ b/test/add-handler.test.js @@ -1,11 +1,10 @@ 'use strict' -const t = require('tap') -const test = t.test +const { test } = require('tap') const addHandler = require('../lib/add-handler') -test('addHandler - ', t => { - test('when existing handler is not defined', t => { +test('The addHandler lib should return the right handlers structure', t => { + t.test('When the existingHandler argument is undefined', t => { t.plan(1) const handlers = addHandler( @@ -15,7 +14,8 @@ test('addHandler - ', t => { t.same(handlers, ['test']) }) - test('when existing handler is a array', t => { + + t.test('When the existingHandler argument is an array', t => { t.plan(1) const handlers = addHandler( @@ -25,7 +25,8 @@ test('addHandler - ', t => { t.same(handlers, ['test', 'again']) }) - test('when existing handler is a function', t => { + + t.test('When the existingHandler argument is a function', t => { t.plan(2) const stub = () => 'test' diff --git a/test/initialization.test.js b/test/initialization.test.js index 0a49788..0eaeec3 100644 --- a/test/initialization.test.js +++ b/test/initialization.test.js @@ -1,7 +1,6 @@ 'use strict' -const t = require('tap') -const test = t.test +const { test } = require('tap') const Fastify = require('fastify') const pg = require('pg') const fastifyPostgres = require('../index') @@ -247,3 +246,36 @@ test('fastify.pg custom namespace should exist if a name is set', (t) => { t.ok(fastify.pg.test.Client) }) }) + +test('fastify.pg and a fastify.pg custom namespace should exist when registering a named instance before an unnamed instance)', async (t) => { + t.plan(10) + + const fastify = Fastify() + t.teardown(() => fastify.close()) + + await fastify.register(fastifyPostgres, { + connectionString, + name: 'one' + }) + + await fastify.register(fastifyPostgres, { + connectionString + }) + + await fastify.ready().catch(err => t.error(err)) + + t.ok(fastify.pg) + t.ok(fastify.pg.connect) + t.ok(fastify.pg.pool) + t.ok(fastify.pg.Client) + + t.ok(fastify.pg.one) + t.ok(fastify.pg.one.connect) + t.ok(fastify.pg.one.pool) + t.ok(fastify.pg.one.Client) + + const result = await fastify.pg.query('SELECT NOW()') + const resultOne = await fastify.pg.one.query('SELECT NOW()') + t.same(result.rowCount, 1) + t.same(resultOne.rowCount, 1) +}) diff --git a/test/req-initialization.test.js b/test/req-initialization.test.js index 707f54a..08a2203 100644 --- a/test/req-initialization.test.js +++ b/test/req-initialization.test.js @@ -1,15 +1,14 @@ 'use strict' -const t = require('tap') -const test = t.test +const { test } = require('tap') const Fastify = require('fastify') const fastifyPostgres = require('../index') const { connectionString } = require('./helpers') const extractUserCount = response => parseInt(JSON.parse(response.payload).rows[0].userCount) -test('fastify postgress useTransaction route option', t => { - test('queries that succeed provided', async t => { +test('When we use the fastify-postgres transaction route option', t => { + t.test('Should be able to execute queries provided to the request pg decorator', async t => { const fastify = Fastify() t.teardown(() => fastify.close()) @@ -40,7 +39,8 @@ test('fastify postgress useTransaction route option', t => { t.equal(extractUserCount(response), 2) }) - test('queries that succeed provided to a namespace', async t => { + + t.test('Should be able to execute queries provided to a namespaced request pg decorator', async t => { const fastify = Fastify() t.teardown(() => fastify.close()) @@ -73,7 +73,8 @@ test('fastify postgress useTransaction route option', t => { t.equal(extractUserCount(response), 2) }) - test('queries that fail provided', async t => { + + t.test('Should trigger a rollback when failing to execute a query provided to the request pg decorator', async t => { const fastify = Fastify() t.teardown(() => fastify.close()) @@ -92,7 +93,43 @@ test('fastify postgress useTransaction route option', t => { fastify.get('/fail', { pg: { transact: true } }, async (req, reply) => { await req.pg.query('INSERT INTO users(username) VALUES($1) RETURNING id', ['fail-opt-in']) await req.pg.query('INSERT INTO users(username) VALUES($1) RETURNING id', ['fail-opt-in']) - await req.pg.query('INSERT INTO nope(username) VALUES($1) RETURNING id', ['fail-opt-in']) + // This one should fail (unknown_table does not exist) and trigger a rollback + await req.pg.query('INSERT INTO unknown_table(username) VALUES($1) RETURNING id', ['fail-opt-in']) + reply.send('complete') + }) + + await fastify.inject({ url: '/fail' }) + + const response = await fastify.inject({ + method: 'GET', + url: '/count-users' + }) + + t.equal(extractUserCount(response), 0) + }) + + t.test('Should trigger a rollback when failing to execute a query provided to a namespaced request pg decorator', async t => { + const fastify = Fastify() + t.teardown(() => fastify.close()) + + await fastify.register(fastifyPostgres, { + connectionString, + name: 'test' + }) + + await fastify.pg.test.query('TRUNCATE users') + + fastify.get('/count-users', async (req, reply) => { + const result = await fastify.pg.test.query('SELECT COUNT(*) AS "userCount" FROM users WHERE username=\'fail-opt-in\'') + + reply.send(result) + }) + + fastify.get('/fail', { pg: { transact: true } }, async (req, reply) => { + await req.pg.test.query('INSERT INTO users(username) VALUES($1) RETURNING id', ['fail-opt-in']) + await req.pg.test.query('INSERT INTO users(username) VALUES($1) RETURNING id', ['fail-opt-in']) + // This one should fail (unknown_table does not exist) and trigger a rollback + await req.pg.test.query('INSERT INTO unknown_table(username) VALUES($1) RETURNING id', ['fail-opt-in']) reply.send('complete') }) @@ -109,8 +146,8 @@ test('fastify postgress useTransaction route option', t => { t.end() }) -test('combinations of registrationOptions.name and routeOptions.pg.transact that should not add hooks', t => { - test('transact not set', t => { +test('Should not add hooks with combinations of registration `options.name` and route options `pg.transact`', t => { + t.test('Should not add hooks when `transact` is not set', t => { t.plan(1) const fastify = Fastify() @@ -126,7 +163,8 @@ test('combinations of registrationOptions.name and routeOptions.pg.transact that fastify.inject({ url: '/' }) }) - test('name set and transact not set', t => { + + t.test('Should not add hooks when `name` is set and `transact` is not set', t => { t.plan(1) const fastify = Fastify() @@ -143,7 +181,8 @@ test('combinations of registrationOptions.name and routeOptions.pg.transact that fastify.inject({ url: '/' }) }) - test('name set and transact set to true', t => { + + t.test('Should not add hooks when `name` is set and `transact` is set to `true`', t => { t.plan(1) const fastify = Fastify() @@ -160,7 +199,8 @@ test('combinations of registrationOptions.name and routeOptions.pg.transact that fastify.inject({ url: '/' }) }) - test('name not set and transact set to string', t => { + + t.test('Should not add hooks when `name` is not set and `transact` is set and is a string', t => { t.plan(1) const fastify = Fastify() @@ -176,7 +216,8 @@ test('combinations of registrationOptions.name and routeOptions.pg.transact that fastify.inject({ url: '/' }) }) - test('name and transact set to different strings', t => { + + t.test('Should not add hooks when `name` and `transact` are set to different strings', t => { t.plan(1) const fastify = Fastify() @@ -193,11 +234,12 @@ test('combinations of registrationOptions.name and routeOptions.pg.transact that fastify.inject({ url: '/' }) }) + t.end() }) -test('incorrect combinations of registrationOptions.name and routeOptions.pg.transact should throw errors', t => { - t.test('name set as reserved keyword', t => { +test('Should throw errors with incorrect combinations of registration `options.name` and route options `pg.transact`', t => { + t.test('Should throw an error when `name` is set as reserved keyword', t => { t.plan(2) const fastify = Fastify() @@ -222,7 +264,7 @@ test('incorrect combinations of registrationOptions.name and routeOptions.pg.tra }) }) - t.test('named pg client has already registered', t => { + t.test('Should throw an error when pg client has already been registered with the same name', t => { t.plan(2) const fastify = Fastify() @@ -249,7 +291,7 @@ test('incorrect combinations of registrationOptions.name and routeOptions.pg.tra }) }) - t.test('pg client has already registered', t => { + t.test('Should throw an error when pg client has already been registered', t => { t.plan(2) const fastify = Fastify() @@ -272,5 +314,6 @@ test('incorrect combinations of registrationOptions.name and routeOptions.pg.tra }) }) }) + t.end() }) From 82980ee923506f58b212dfb606463f2d31919a44 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Sep 2021 13:44:49 +0000 Subject: [PATCH 03/20] Bump fastify/github-action-merge-dependabot from 2.4.0 to 2.5.0 (#109) Bumps [fastify/github-action-merge-dependabot](https://github.com/fastify/github-action-merge-dependabot) from 2.4.0 to 2.5.0. - [Release notes](https://github.com/fastify/github-action-merge-dependabot/releases) - [Commits](https://github.com/fastify/github-action-merge-dependabot/compare/v2.4.0...v2.5.0) --- updated-dependencies: - dependency-name: fastify/github-action-merge-dependabot dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcc16fb..d4fcc32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,6 +78,6 @@ jobs: needs: test runs-on: ubuntu-latest steps: - - uses: fastify/github-action-merge-dependabot@v2.4.0 + - uses: fastify/github-action-merge-dependabot@v2.5.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} From 079111459d5abcbe381c8c98888d0a136a5dec74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Oct 2021 04:09:46 +0000 Subject: [PATCH 04/20] Bump tsd from 0.17.0 to 0.18.0 (#112) Bumps [tsd](https://github.com/SamVerschueren/tsd) from 0.17.0 to 0.18.0. - [Release notes](https://github.com/SamVerschueren/tsd/releases) - [Commits](https://github.com/SamVerschueren/tsd/compare/v0.17.0...v0.18.0) --- updated-dependencies: - dependency-name: tsd dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6231ec1..ecb19b4 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "pg-native": "^3.0.0", "standard": "^16.0.3", "tap": "^15.0.10", - "tsd": "^0.17.0", + "tsd": "^0.18.0", "typescript": "^4.4.3" }, "peerDependencies": { From 810368f596d8f5b173ea6b99d620a75a9f8dc377 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Oct 2021 04:14:39 +0000 Subject: [PATCH 05/20] Bump actions/checkout from 2.3.4 to 2.3.5 (#113) Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.4 to 2.3.5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2.3.4...v2.3.5) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4fcc32..4c825d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v2.3.5 - name: Use Node.js uses: actions/setup-node@v2.4.0 From 7cf90d78e5369f61d4bd41bed346d3fcf1831d23 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Oct 2021 04:27:55 +0000 Subject: [PATCH 06/20] Bump actions/setup-node from 2.4.0 to 2.4.1 (#111) Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2.4.0 to 2.4.1. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v2.4.0...v2.4.1) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c825d7..9c4a289 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v2.3.5 - name: Use Node.js - uses: actions/setup-node@v2.4.0 + uses: actions/setup-node@v2.4.1 with: node-version: ${{ matrix.node-version }} From 0c04ee50244459e799a64b7e36c12f3becdb0e8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Nov 2021 04:11:47 +0000 Subject: [PATCH 07/20] Bump actions/checkout from 2.3.5 to 2.4.0 (#114) Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.5 to 2.4.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2.3.5...v2.4.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c4a289..843d60e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - uses: actions/checkout@v2.3.5 + - uses: actions/checkout@v2.4.0 - name: Use Node.js uses: actions/setup-node@v2.4.1 From e93cf859d8a52583be55d3dbaff4b36725d34f1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Nov 2021 04:11:37 +0000 Subject: [PATCH 08/20] Bump tsd from 0.18.0 to 0.19.0 (#115) Bumps [tsd](https://github.com/SamVerschueren/tsd) from 0.18.0 to 0.19.0. - [Release notes](https://github.com/SamVerschueren/tsd/releases) - [Commits](https://github.com/SamVerschueren/tsd/compare/v0.18.0...v0.19.0) --- updated-dependencies: - dependency-name: tsd dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ecb19b4..0572bdd 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "pg-native": "^3.0.0", "standard": "^16.0.3", "tap": "^15.0.10", - "tsd": "^0.18.0", + "tsd": "^0.19.0", "typescript": "^4.4.3" }, "peerDependencies": { From fd401bbf6fa19e22d01a76ab8551323821a514ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Nov 2021 04:13:03 +0000 Subject: [PATCH 09/20] Bump fastify/github-action-merge-dependabot from 2.5.0 to 2.6.0 (#116) Bumps [fastify/github-action-merge-dependabot](https://github.com/fastify/github-action-merge-dependabot) from 2.5.0 to 2.6.0. - [Release notes](https://github.com/fastify/github-action-merge-dependabot/releases) - [Commits](https://github.com/fastify/github-action-merge-dependabot/compare/v2.5.0...v2.6.0) --- updated-dependencies: - dependency-name: fastify/github-action-merge-dependabot dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 843d60e..3079c37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,6 +78,6 @@ jobs: needs: test runs-on: ubuntu-latest steps: - - uses: fastify/github-action-merge-dependabot@v2.5.0 + - uses: fastify/github-action-merge-dependabot@v2.6.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} From 8249e12b506185246c961297d9bef5a9271f1047 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Wed, 24 Nov 2021 14:59:06 +0000 Subject: [PATCH 10/20] build(dependabot): ignore minor and patch github-actions updates (#117) --- .github/dependabot.yml | 4 ++++ .github/workflows/ci.yml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5e48d4e..e549772 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,6 +2,10 @@ version: 2 updates: - package-ecosystem: github-actions directory: '/' + ignore: + - dependency-name: "actions/*" + update-types: + ["version-update:semver-minor", "version-update:semver-patch"] schedule: interval: daily open-pull-requests-limit: 10 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3079c37..4b6b103 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,10 +31,10 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - uses: actions/checkout@v2.4.0 + - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v2.4.1 + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} From 1c36b1fac1a7eed49902e11abfa6d31e5b6eb1c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Dec 2021 04:14:56 +0000 Subject: [PATCH 11/20] Bump fastify/github-action-merge-dependabot from 2.6.0 to 2.7.0 (#118) Bumps [fastify/github-action-merge-dependabot](https://github.com/fastify/github-action-merge-dependabot) from 2.6.0 to 2.7.0. - [Release notes](https://github.com/fastify/github-action-merge-dependabot/releases) - [Commits](https://github.com/fastify/github-action-merge-dependabot/compare/v2.6.0...v2.7.0) --- updated-dependencies: - dependency-name: fastify/github-action-merge-dependabot dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b6b103..c4d140e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,6 +78,6 @@ jobs: needs: test runs-on: ubuntu-latest steps: - - uses: fastify/github-action-merge-dependabot@v2.6.0 + - uses: fastify/github-action-merge-dependabot@v2.7.0 with: github-token: ${{ secrets.GITHUB_TOKEN }} From 541d02bebc79e04224c52659702a88cb3b95ef62 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Dec 2021 04:12:37 +0000 Subject: [PATCH 12/20] Bump fastify/github-action-merge-dependabot from 2.7.0 to 2.7.1 (#119) Bumps [fastify/github-action-merge-dependabot](https://github.com/fastify/github-action-merge-dependabot) from 2.7.0 to 2.7.1. - [Release notes](https://github.com/fastify/github-action-merge-dependabot/releases) - [Commits](https://github.com/fastify/github-action-merge-dependabot/compare/v2.7.0...v2.7.1) --- updated-dependencies: - dependency-name: fastify/github-action-merge-dependabot dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4d140e..5798e05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,6 +78,6 @@ jobs: needs: test runs-on: ubuntu-latest steps: - - uses: fastify/github-action-merge-dependabot@v2.7.0 + - uses: fastify/github-action-merge-dependabot@v2.7.1 with: github-token: ${{ secrets.GITHUB_TOKEN }} From acac8a491c7f99f9183323593b46c71e5e431246 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Sun, 19 Dec 2021 18:47:06 +0100 Subject: [PATCH 13/20] chore: upgrade github-action-merge-dependabot to v3 (#121) --- .github/workflows/ci.yml | 89 ++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5798e05..4d658ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,22 +1,23 @@ name: CI - -on: +'on': push: paths-ignore: - - 'docs/**' + - docs/** - '*.md' pull_request: paths-ignore: - - 'docs/**' + - docs/** - '*.md' - jobs: test: runs-on: ubuntu-latest strategy: matrix: - node-version: [10, 12, 14, 16] - + node-version: + - 10 + - 12 + - 14 + - 16 services: postgres: image: postgres:11-alpine @@ -25,45 +26,43 @@ jobs: POSTGRES_DB: postgres POSTGRES_PASSWORD: postgres ports: - # will assign a random free host port - - 5432:5432 - # needed because the postgres container does not provide a healthcheck - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - + - '5432:5432' + options: >- + --health-cmd pg_isready --health-interval 10s --health-timeout 5s + --health-retries 5 steps: - - uses: actions/checkout@v2 - - - name: Use Node.js - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: | - npm install - - - name: CI environment setup - run: | - npm i node-gyp - sudo apt-get install -yqq libpq-dev postgresql-client - chmod 600 .pgpass - PGPASSFILE=.pgpass psql -h localhost -p ${{ job.services.postgres.ports[5432] }} -d postgres -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U postgres - - - name: Check licenses - run: | - npm run license-checker --if-present + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - name: Install Dependencies + run: | + npm install + - name: CI environment setup + run: > + npm i node-gyp - - name: Run tests - run: | - npm run test:ci + sudo apt-get install -yqq libpq-dev postgresql-client - - name: Coveralls Parallel - uses: coverallsapp/github-action@1.1.3 - with: - github-token: ${{ secrets.github_token }} - parallel: true - flag-name: run-${{ matrix.node-version }}-${{ matrix.os }} + chmod 600 .pgpass + PGPASSFILE=.pgpass psql -h localhost -p ${{ + job.services.postgres.ports[5432] }} -d postgres -c 'CREATE TABLE + users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U + postgres + - name: Check licenses + run: | + npm run license-checker --if-present + - name: Run tests + run: | + npm run test:ci + - name: Coveralls Parallel + uses: coverallsapp/github-action@1.1.3 + with: + github-token: ${{ secrets.github_token }} + parallel: true + flag-name: run-${{ matrix.node-version }}-${{ matrix.os }} coverage: needs: test runs-on: ubuntu-latest @@ -73,11 +72,13 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true - automerge: needs: test runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write steps: - - uses: fastify/github-action-merge-dependabot@v2.7.1 + - uses: fastify/github-action-merge-dependabot@v3 with: github-token: ${{ secrets.GITHUB_TOKEN }} From 39b5b527ec80cf62c8d795fa12b35a85f521ebee Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Thu, 27 Jan 2022 08:40:01 +0000 Subject: [PATCH 14/20] build: reduce dependabot update frequency (#122) --- .github/dependabot.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e549772..dfa7fa6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,16 +1,13 @@ version: 2 updates: - - package-ecosystem: github-actions - directory: '/' - ignore: - - dependency-name: "actions/*" - update-types: - ["version-update:semver-minor", "version-update:semver-patch"] + - package-ecosystem: "github-actions" + directory: "/" schedule: - interval: daily + interval: "monthly" open-pull-requests-limit: 10 - - package-ecosystem: npm - directory: '/' + + - package-ecosystem: "npm" + directory: "/" schedule: - interval: daily + interval: "weekly" open-pull-requests-limit: 10 From b06da735fbd51c5ba43e2078ad16ebfdb9440f88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Mar 2022 04:04:33 +0000 Subject: [PATCH 15/20] Bump actions/setup-node from 2 to 3 (#123) Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2 to 3. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d658ae..f0c6521 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Use Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: Install Dependencies From e0a65bb8eed641a62d03a0f7194d0acc12e31a5f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Mar 2022 04:08:43 +0000 Subject: [PATCH 16/20] Bump tap from 15.2.3 to 16.0.0 (#124) Bumps [tap](https://github.com/tapjs/node-tap) from 15.2.3 to 16.0.0. - [Release notes](https://github.com/tapjs/node-tap/releases) - [Commits](https://github.com/tapjs/node-tap/compare/v15.2.3...v16.0.0) --- updated-dependencies: - dependency-name: tap dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0572bdd..0c5a6cf 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "pg": "^8.7.1", "pg-native": "^3.0.0", "standard": "^16.0.3", - "tap": "^15.0.10", + "tap": "^16.0.0", "tsd": "^0.19.0", "typescript": "^4.4.3" }, From 5df13e2edc88c10848471d50dc5656fe1ed1891e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 04:05:19 +0000 Subject: [PATCH 17/20] Bump actions/checkout from 2 to 3 (#125) Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0c6521..9fc1fa2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js uses: actions/setup-node@v3 with: From 79f52c32dbe7772034166dea9704f5f92c44331c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Apr 2022 04:07:34 +0000 Subject: [PATCH 18/20] Bump tsd from 0.19.1 to 0.20.0 (#126) Bumps [tsd](https://github.com/SamVerschueren/tsd) from 0.19.1 to 0.20.0. - [Release notes](https://github.com/SamVerschueren/tsd/releases) - [Commits](https://github.com/SamVerschueren/tsd/compare/v0.19.1...v0.20.0) --- updated-dependencies: - dependency-name: tsd dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c5a6cf..c992bd5 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "pg-native": "^3.0.0", "standard": "^16.0.3", "tap": "^16.0.0", - "tsd": "^0.19.0", + "tsd": "^0.20.0", "typescript": "^4.4.3" }, "peerDependencies": { From 19aabe95147c258ec52fc878cea11a1588978fd3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Apr 2022 04:06:20 +0000 Subject: [PATCH 19/20] build(deps-dev): bump standard from 16.0.4 to 17.0.0 (#127) Bumps [standard](https://github.com/standard/standard) from 16.0.4 to 17.0.0. - [Release notes](https://github.com/standard/standard/releases) - [Changelog](https://github.com/standard/standard/blob/master/CHANGELOG.md) - [Commits](https://github.com/standard/standard/compare/v16.0.4...v17.0.0) --- updated-dependencies: - dependency-name: standard dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c992bd5..cd0ae6d 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "fastify": "^3.21.5", "pg": "^8.7.1", "pg-native": "^3.0.0", - "standard": "^16.0.3", + "standard": "^17.0.0", "tap": "^16.0.0", "tsd": "^0.20.0", "typescript": "^4.4.3" From 59795cfd958b884d96aedfb739cf365c240518b0 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Wed, 27 Apr 2022 09:03:29 -0400 Subject: [PATCH 20/20] Rename Module This commit renames the module in accordance with the discussion in fastify/fastify/issues/3733 . --- package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cd0ae6d..58d2760 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "fastify-postgres", - "version": "3.6.0", + "name": "@fastify/postgres", + "version": "4.0.0", "description": "Fastify PostgreSQL connection plugin", "main": "index.js", "types": "index.d.ts", @@ -52,5 +52,8 @@ }, "tsd": { "directory": "test/types" + }, + "publishConfig": { + "access": "public" } }