Skip to content

Commit ba40f0c

Browse files
authored
Update fastify to v3 (#44)
* update fastify to v3 * add dependabot config * add github actions config * add plugin version * update fastify version
1 parent 9e26e83 commit ba40f0c

File tree

9 files changed

+40
-25
lines changed

9 files changed

+40
-25
lines changed

.dependabot/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: 1
2+
update_configs:
3+
- package_manager: "javascript"
4+
directory: "/"
5+
update_schedule: "daily"

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: CI workflow
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
node-version: [10.x, 12.x, 14.x]
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Use Node.js ${{ matrix.node-version }}
12+
uses: actions/setup-node@v1
13+
with:
14+
node-version: ${{ matrix.node-version }}
15+
- name: Install Dependencies
16+
run: npm install --ignore-scripts
17+
- name: Test
18+
run: npm test

.travis.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# fastify-oauth2
22

3+
![CI workflow](https://github.com/fastify/fastify-oauth2/workflows/CI%20workflow/badge.svg)
4+
35
Wrap around [`simple-oauth2`](https://github.com/lelylan/simple-oauth2) library.
46

57
## Install

index.d.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import * as fastify from 'fastify';
2-
import * as http from 'http';
1+
import { FastifyRequest, FastifyInstance, RawServerBase, RawRequestDefaultExpression, RawReplyDefaultExpression, FastifyError } from 'fastify';
32

4-
declare function fastifyOauth2(
5-
instance: fastify.FastifyInstance<http.Server, http.IncomingMessage, http.ServerResponse>,
6-
options: fastifyOauth2.FastifyOAuth2Options,
7-
callback: (err?: fastify.FastifyError) => void,
3+
declare function fastifyOauth2 (
4+
instance: FastifyInstance<RawServerBase, RawRequestDefaultExpression<RawServerBase>, RawReplyDefaultExpression<RawServerBase>>,
5+
opts: fastifyOauth2.FastifyOAuth2Options,
6+
next: (err?: FastifyError) => void
87
): void;
98

109
declare namespace fastifyOauth2 {
@@ -25,11 +24,11 @@ declare namespace fastifyOauth2 {
2524

2625
interface OAuth2Namespace {
2726
getAccessTokenFromAuthorizationCodeFlow(
28-
request: fastify.FastifyRequest<http.IncomingMessage>,
27+
request: FastifyRequest,
2928
): Promise<OAuth2Token>;
3029

3130
getAccessTokenFromAuthorizationCodeFlow(
32-
request: fastify.FastifyRequest<http.IncomingMessage>,
31+
request: FastifyRequest,
3332
callback: (token: OAuth2Token) => void,
3433
): void;
3534

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ const oauthPlugin = fp(function (fastify, options, next) {
132132
}
133133

134134
next()
135+
}, {
136+
fastify: '>=3.x',
137+
name: 'fastify-oauth2'
135138
})
136139

137140
oauthPlugin.FACEBOOK_CONFIGURATION = {

index.test-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import * as fastify from 'fastify';
1+
import fastify, { FastifyInstance } from 'fastify';
22
import * as fastifyOauth2 from '.';
33
import { expectType, expectError, expectAssignable } from 'tsd';
4+
import { Server, IncomingMessage, ServerResponse } from 'http';
45

56
/**
67
* Preparing some data for testing.
@@ -43,7 +44,6 @@ expectType<fastifyOauth2.ProviderConfiguration>(auth);
4344
expectType<string[]>(scope);
4445
expectType<fastifyOauth2.Credentials>(credentials);
4546

46-
expectType<void>(fastifyOauth2(server, OAuth2Options, () => {}));
4747
expectError(fastifyOauth2()); // error because missing required arguments
4848
expectError(fastifyOauth2(server, {}, () => {})); // error because missing required options
4949

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
],
2626
"homepage": "https://github.com/fastify/fastify-oauth2#readme",
2727
"devDependencies": {
28-
"fastify": "^2.0.1",
28+
"fastify": "^3.0.0-rc.1",
2929
"nock": "^9.0.0",
3030
"pre-commit": "^1.2.2",
3131
"simple-get": "^3.0.2",
@@ -36,7 +36,7 @@
3636
},
3737
"dependencies": {
3838
"es6-promisify": "^6.0.0",
39-
"fastify-plugin": "^1.0.1",
39+
"fastify-plugin": "^2.0.0",
4040
"simple-oauth2": "^1.6.0"
4141
}
4242
}

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,6 @@ t.test('already decorated', t => {
479479
callbackUri: '/callback'
480480
})
481481
.ready(err => {
482-
t.strictSame(err.message, 'FST_ERR_DEC_ALREADY_PRESENT: The decorator \'githubOAuth2\' has already been added!')
482+
t.strictSame(err.message, 'The decorator \'githubOAuth2\' has already been added!')
483483
})
484484
})

0 commit comments

Comments
 (0)