Skip to content

Commit 0a98afa

Browse files
frikilleEommmcollina
authored
Update fastify to v3 (#60)
* update fastify to v3 * remove node 6 and 8 * remove greenkeeper badge * update github actions config * add pgpass file * update github actions config * update connection string * remove travis config * update docker commands * add build status badge * Update package.json Co-authored-by: Manuel Spigolon <[email protected]> Co-authored-by: Manuel Spigolon <[email protected]> Co-authored-by: Matteo Collina <[email protected]>
1 parent c352d34 commit 0a98afa

File tree

7 files changed

+46
-75
lines changed

7 files changed

+46
-75
lines changed

.github/workflows/ci.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: GitHub CI
1+
name: CI workflow
22

33
on: [push, pull_request]
44

@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
node: [6, 8, 10, 12, 13]
10+
node: [10, 12, 14]
1111

1212
name: Node.js ${{ matrix.node }}
1313

@@ -17,6 +17,7 @@ jobs:
1717
env:
1818
POSTGRES_USER: postgres
1919
POSTGRES_DB: postgres
20+
POSTGRES_PASSWORD: postgres
2021
ports:
2122
# will assign a random free host port
2223
- 5432:5432
@@ -32,7 +33,8 @@ jobs:
3233
run: |
3334
npm i node-gyp
3435
sudo apt-get install -yqq libpq-dev postgresql-client
35-
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
36+
chmod 600 .pgpass
37+
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
3638
3739
- name: Install
3840
run: npm install

.pgpass

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
localhost:*:*:postgres:postgres

.travis.yml

-27
This file was deleted.

package.json

+4-9
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"test": "standard && tap -J test/*.test.js",
88
"test:report": "standard && tap -J --coverage-report=html test/*.test.js",
99
"test:verbose": "standard && tap -J test/*.test.js -Rspec",
10-
"load-data": "docker run --rm -d --link fastify-postgres:postgres postgres:11-alpine psql -h postgres -d postgres -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U postgres",
11-
"postgres": "docker run --rm -d -p 5432:5432 --name fastify-postgres postgres:11-alpine"
10+
"postgres": "docker run -p 5432:5432 --name fastify-postgres -e POSTGRES_PASSWORD=postgres -d postgres:11-alpine",
11+
"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"
1212
},
1313
"repository": {
1414
"type": "git",
@@ -29,21 +29,16 @@
2929
},
3030
"homepage": "https://github.com/fastify/fastify-postgres#readme",
3131
"dependencies": {
32-
"fastify-plugin": "^1.5.0"
32+
"fastify-plugin": "^2.0.0"
3333
},
3434
"devDependencies": {
35-
"fastify": "^2.7.1",
35+
"fastify": "^3.0.0-rc.1",
3636
"pg": "*",
3737
"pg-native": "^3.0.0",
3838
"standard": "^13.0.1",
3939
"tap": "^12.7.0"
4040
},
4141
"peerDependencies": {
4242
"pg": ">=6.0.0"
43-
},
44-
"greenkeeper": {
45-
"ignore": [
46-
"tap"
47-
]
4843
}
4944
}

test/initialization.test.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test('Should be able to use native module', (t) => {
1212
t.teardown(() => fastify.close())
1313

1414
fastify.register(fastifyPostgres, {
15-
connectionString: 'postgres://postgres@localhost/postgres',
15+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
1616
native: true
1717
})
1818

@@ -38,7 +38,7 @@ test('Should be able to use an alternative pg module', (t) => {
3838
t.teardown(() => fastify.close())
3939

4040
fastify.register(fastifyPostgres, {
41-
connectionString: 'postgres://postgres@localhost/postgres',
41+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
4242
pg: altPg
4343
})
4444

@@ -64,20 +64,20 @@ test('Should not throw if registered within different scopes (with and without n
6464

6565
fastify.register(function scopeOne (instance, opts, next) {
6666
instance.register(fastifyPostgres, {
67-
connectionString: 'postgres://postgres@localhost/postgres'
67+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
6868
})
6969

7070
next()
7171
})
7272

7373
fastify.register(function scopeTwo (instance, opts, next) {
7474
instance.register(fastifyPostgres, {
75-
connectionString: 'postgres://postgres@localhost/postgres',
75+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
7676
name: 'one'
7777
})
7878

7979
instance.register(fastifyPostgres, {
80-
connectionString: 'postgres://postgres@localhost/postgres',
80+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
8181
name: 'two'
8282
})
8383

@@ -97,11 +97,11 @@ test('Should throw when trying to register multiple instances without giving a n
9797
t.teardown(() => fastify.close())
9898

9999
fastify.register(fastifyPostgres, {
100-
connectionString: 'postgres://postgres@localhost/postgres'
100+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
101101
})
102102

103103
fastify.register(fastifyPostgres, {
104-
connectionString: 'postgres://postgres@localhost/postgres'
104+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
105105
})
106106

107107
fastify.ready((err) => {
@@ -119,13 +119,13 @@ test('Should throw when trying to register duplicate connection names', (t) => {
119119

120120
fastify
121121
.register(fastifyPostgres, {
122-
connectionString: 'postgres://postgres@localhost/postgres',
123-
name
124-
})
125-
.register(fastifyPostgres, {
126-
connectionString: 'postgres://postgres@localhost/postgres',
122+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
127123
name
128124
})
125+
fastify.register(fastifyPostgres, {
126+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
127+
name
128+
})
129129

130130
fastify.ready((err) => {
131131
t.ok(err)
@@ -140,7 +140,7 @@ test('fastify.pg namespace should exist', (t) => {
140140
t.teardown(() => fastify.close())
141141

142142
fastify.register(fastifyPostgres, {
143-
connectionString: 'postgres://postgres@localhost/postgres'
143+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
144144
})
145145

146146
fastify.ready((err) => {
@@ -160,7 +160,7 @@ test('fastify.pg.test namespace should exist', (t) => {
160160
t.teardown(() => fastify.close())
161161

162162
fastify.register(fastifyPostgres, {
163-
connectionString: 'postgres://postgres@localhost/postgres',
163+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
164164
name: 'test'
165165
})
166166

test/query.test.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test('When fastify.pg root namespace is used:', (t) => {
1313
t.teardown(() => fastify.close())
1414

1515
fastify.register(fastifyPostgres, {
16-
connectionString: 'postgres://postgres@localhost/postgres'
16+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
1717
})
1818

1919
fastify.ready((err) => {
@@ -40,7 +40,7 @@ test('When fastify.pg root namespace is used:', (t) => {
4040
t.teardown(() => fastify.close())
4141

4242
fastify.register(fastifyPostgres, {
43-
connectionString: 'postgres://postgres@localhost/postgres'
43+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
4444
})
4545

4646
fastify.ready((err) => {
@@ -60,7 +60,7 @@ test('When fastify.pg root namespace is used:', (t) => {
6060
t.teardown(() => fastify.close())
6161

6262
fastify.register(fastifyPostgres, {
63-
connectionString: 'postgres://postgres@localhost/postgres'
63+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
6464
})
6565

6666
fastify.ready((err) => {
@@ -88,7 +88,7 @@ test('When fastify.pg root namespace is used:', (t) => {
8888
const DB_NAME = 'database_that_do_not_exist'
8989

9090
fastify.register(fastifyPostgres, {
91-
connectionString: `postgres://postgres@localhost/${DB_NAME}`
91+
connectionString: `postgres://postgres:postgres@localhost/${DB_NAME}`
9292
})
9393

9494
fastify.ready((err) => {
@@ -112,7 +112,7 @@ test('When fastify.pg root namespace is used:', (t) => {
112112
const DB_NAME = 'database_that_do_not_exist'
113113

114114
fastify.register(fastifyPostgres, {
115-
connectionString: `postgres://postgres@localhost/${DB_NAME}`
115+
connectionString: `postgres://postgres:postgres@localhost/${DB_NAME}`
116116
})
117117

118118
fastify.ready((err) => {
@@ -141,7 +141,7 @@ test('When fastify.pg.test namespace is used:', (t) => {
141141
t.teardown(() => fastify.close())
142142

143143
fastify.register(fastifyPostgres, {
144-
connectionString: 'postgres://postgres@localhost/postgres',
144+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
145145
name: 'test'
146146
})
147147

@@ -167,7 +167,7 @@ test('When fastify.pg.test namespace is used:', (t) => {
167167
t.teardown(() => fastify.close())
168168

169169
fastify.register(fastifyPostgres, {
170-
connectionString: 'postgres://postgres@localhost/postgres',
170+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
171171
name: 'test'
172172
})
173173

@@ -187,7 +187,7 @@ test('When fastify.pg.test namespace is used:', (t) => {
187187
t.teardown(() => fastify.close())
188188

189189
fastify.register(fastifyPostgres, {
190-
connectionString: 'postgres://postgres@localhost/postgres',
190+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
191191
name: 'test'
192192
})
193193

@@ -212,7 +212,7 @@ test('When fastify.pg.test namespace is used:', (t) => {
212212
t.teardown(() => fastify.close())
213213

214214
fastify.register(fastifyPostgres, {
215-
connectionString: 'postgres://postgres@localhost/postgres',
215+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
216216
name: 'test',
217217
native: true
218218
})
@@ -240,7 +240,7 @@ test('When fastify.pg.test namespace is used:', (t) => {
240240
const DB_NAME = 'database_that_do_not_exist'
241241

242242
fastify.register(fastifyPostgres, {
243-
connectionString: `postgres://postgres@localhost/${DB_NAME}`,
243+
connectionString: `postgres://postgres:postgres@localhost/${DB_NAME}`,
244244
name: 'test'
245245
})
246246

test/transaction.test.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ test('When fastify.pg root namespace is used:', (t) => {
1313
t.teardown(() => fastify.close())
1414

1515
fastify.register(fastifyPostgres, {
16-
connectionString: 'postgres://postgres@localhost/postgres'
16+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
1717
})
1818

1919
fastify.ready((err) => {
@@ -50,7 +50,7 @@ test('When fastify.pg root namespace is used:', (t) => {
5050
t.teardown(() => fastify.close())
5151

5252
fastify.register(fastifyPostgres, {
53-
connectionString: 'postgres://postgres@localhost/postgres'
53+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
5454
})
5555

5656
fastify.ready((err) => {
@@ -87,7 +87,7 @@ test('When fastify.pg root namespace is used:', (t) => {
8787
t.teardown(() => fastify.close())
8888

8989
fastify.register(fastifyPostgres, {
90-
connectionString: 'postgres://postgres@localhost/postgres'
90+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
9191
})
9292

9393
fastify.ready((err) => {
@@ -128,7 +128,7 @@ test('When fastify.pg root namespace is used:', (t) => {
128128
t.teardown(() => fastify.close())
129129

130130
fastify.register(fastifyPostgres, {
131-
connectionString: 'postgres://postgres@localhost/postgres'
131+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
132132
})
133133

134134
fastify.ready((err) => {
@@ -182,7 +182,7 @@ test('When fastify.pg root namespace is used:', (t) => {
182182
t.teardown(() => fastify.close())
183183

184184
fastify.register(fastifyPostgres, {
185-
connectionString: 'postgres://postgres@localhost/postgres'
185+
connectionString: 'postgres://postgres:postgres@localhost/postgres'
186186
})
187187

188188
fastify.ready((err) => {
@@ -234,7 +234,7 @@ test('When fastify.pg root namespace is used:', (t) => {
234234
const BAD_DB_NAME = 'db_that_does_not_exist'
235235

236236
fastify.register(fastifyPostgres, {
237-
connectionString: `postgres://postgres@localhost/${BAD_DB_NAME}`
237+
connectionString: `postgres://postgres:postgres@localhost/${BAD_DB_NAME}`
238238
})
239239

240240
fastify.ready((err) => {
@@ -259,7 +259,7 @@ test('When fastify.pg.test namespace is used:', (t) => {
259259
t.teardown(() => fastify.close())
260260

261261
fastify.register(fastifyPostgres, {
262-
connectionString: 'postgres://postgres@localhost/postgres',
262+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
263263
name: 'test'
264264
})
265265

@@ -297,7 +297,7 @@ test('When fastify.pg.test namespace is used:', (t) => {
297297
t.teardown(() => fastify.close())
298298

299299
fastify.register(fastifyPostgres, {
300-
connectionString: 'postgres://postgres@localhost/postgres',
300+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
301301
name: 'test'
302302
})
303303

@@ -337,7 +337,7 @@ test('When fastify.pg.test namespace is used:', (t) => {
337337
t.teardown(() => fastify.close())
338338

339339
fastify.register(fastifyPostgres, {
340-
connectionString: 'postgres://postgres@localhost/postgres',
340+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
341341
name: 'test'
342342
})
343343

@@ -380,7 +380,7 @@ test('When fastify.pg.test namespace is used:', (t) => {
380380
t.teardown(() => fastify.close())
381381

382382
fastify.register(fastifyPostgres, {
383-
connectionString: 'postgres://postgres@localhost/postgres',
383+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
384384
name: 'test'
385385
})
386386

@@ -435,7 +435,7 @@ test('When fastify.pg.test namespace is used:', (t) => {
435435
t.teardown(() => fastify.close())
436436

437437
fastify.register(fastifyPostgres, {
438-
connectionString: 'postgres://postgres@localhost/postgres',
438+
connectionString: 'postgres://postgres:postgres@localhost/postgres',
439439
name: 'test'
440440
})
441441

@@ -488,7 +488,7 @@ test('When fastify.pg.test namespace is used:', (t) => {
488488
const BAD_DB_NAME = 'db_that_does_not_exist'
489489

490490
fastify.register(fastifyPostgres, {
491-
connectionString: `postgres://postgres@localhost/${BAD_DB_NAME}`,
491+
connectionString: `postgres://postgres:postgres@localhost/${BAD_DB_NAME}`,
492492
name: 'test'
493493
})
494494

0 commit comments

Comments
 (0)