Skip to content

Commit 6c5eca9

Browse files
authored
chore: ci updates and style change (#87)
1 parent 4922863 commit 6c5eca9

File tree

3 files changed

+44
-23
lines changed

3 files changed

+44
-23
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,39 @@
1-
name: CI workflow
2-
on: [push, pull_request]
1+
name: CI
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'docs/**'
7+
- '*.md'
8+
pull_request:
9+
paths-ignore:
10+
- 'docs/**'
11+
- '*.md'
12+
313
jobs:
414
test:
5-
runs-on: ubuntu-latest
15+
runs-on: ${{ matrix.os }}
16+
617
strategy:
718
matrix:
819
node-version: [10.x, 12.x, 14.x]
20+
os: [macos-latest, ubuntu-latest, windows-latest]
21+
922
steps:
10-
- uses: actions/checkout@v2
11-
- name: Use Node.js ${{ matrix.node-version }}
12-
uses: actions/[email protected]
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
23+
- uses: actions/checkout@v2
24+
25+
- name: Use Node.js
26+
uses: actions/[email protected]
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
30+
- name: Install Dependencies
31+
run: |
32+
npm install --ignore-scripts
33+
34+
- name: Run Tests
35+
run: |
36+
npm run test
1937
2038
automerge:
2139
needs: test
@@ -24,4 +42,4 @@ jobs:
2442
- uses: fastify/[email protected]
2543
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }}
2644
with:
27-
github-token: ${{secrets.github_token}}
45+
github-token: ${{ secrets.GITHUB_TOKEN }}

README.md

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

3-
![CI workflow](https://github.com/fastify/fastify-oauth2/workflows/CI%20workflow/badge.svg)
3+
![CI](https://github.com/fastify/fastify-oauth2/workflows/CI/badge.svg)
4+
[![NPM version](https://img.shields.io/npm/v/fastify-oauth2.svg?style=flat)](https://www.npmjs.com/package/fastify-oauth2)
5+
[![Known Vulnerabilities](https://snyk.io/test/github/fastify/fastify-oauth2/badge.svg)](https://snyk.io/test/github/fastify/fastify-oauth2)
6+
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
47

5-
Wrap around [`simple-oauth2`](https://github.com/lelylan/simple-oauth2) library.
8+
Wrapper around the [`simple-oauth2`](https://github.com/lelylan/simple-oauth2) library.
69

710
v4.x of this module support Fastify v3.x
811
[v3.x](https://github.com/fastify/fastify-oauth2/tree/3.x) of this module support Fastify v2.x
@@ -63,7 +66,7 @@ You can choose some default setup to assign to `auth` option.
6366

6467
### Custom configuration
6568

66-
Of course you can set the OAUTH endpoints by yourself if a preset is not in our module:
69+
Of course, you can set the OAUTH endpoints by yourself if a preset is not in our module:
6770

6871
```js
6972
fastify.register(oauthPlugin, {
@@ -157,7 +160,7 @@ See the [`example/`](./examples/) folder for more example.
157160

158161
## Reference
159162

160-
This fastify plugin decorates the fastify instance with the [`simple-oauth2`](https://github.com/lelylan/simple-oauth2)
163+
This Fastify plugin decorates the fastify instance with the [`simple-oauth2`](https://github.com/lelylan/simple-oauth2)
161164
instance inside a **namespace** specified by the property `name`.
162165

163166
E.g. For `name: 'customOauth2'`, the `simple-oauth2` instance will become accessible like this:
@@ -189,8 +192,8 @@ This fastify plugin adds 3 utility decorators to your fastify instance using the
189192
- `refresh_token` (optional, only if the `offline scope` was originally requested)
190193
- `token_type` (generally `'bearer'`)
191194
- `expires_in` (number of seconds for the token to expire, e.g. `240000`)
192-
- `getNewAccessTokenUsingRefreshToken(refreshToken, params, callback)`: A function that takes a refresh token and retrieves a new *token response* object. This is generally useful with background processing workers to re-issue a new token when the original token has expired. The `params` argument is optional and it's an object that can be used to pass in extra parameters to the refresh request (e.g. a stricter set of scopes). If the callback is not passed this function will return a promise. The object resulting from the callback call or the promise resolution is a new *token response* object (see fields above).
193-
- `generateAuthorizationUri(requestObject)`: A function that returns the authorization uri. This is generally useful when you want to handle the redirect yourself in a specific route. The `requestObject` argument passes the request object to the `generateStateFunction`). You **don't** need to declare a `startRedirectPath` if you use this approach. Example of how you would use it:
195+
- `getNewAccessTokenUsingRefreshToken(refreshToken, params, callback)`: A function that takes a refresh token and retrieves a new *token response* object. This is generally useful with background processing workers to re-issue a new token when the original token has expired. The `params` argument is optional and it is an object that can be used to pass in extra parameters to the refresh request (e.g. a stricter set of scopes). If the callback is not passed this function will return a promise. The object resulting from the callback call or the promise resolution is a new *token response* object (see fields above).
196+
- `generateAuthorizationUri(requestObject)`: A function that returns the authorization uri. This is generally useful when you want to handle the redirect yourself in a specific route. The `requestObject` argument passes the request object to the `generateStateFunction`). You **do not** need to declare a `startRedirectPath` if you use this approach. Example of how you would use it:
194197

195198
```js
196199
fastify.get('/external', { /* Hooks can be used here */ }, async (req, reply) => {
@@ -204,9 +207,9 @@ E.g. For `name: 'customOauth2'`, the helpers `getAccessTokenFromAuthorizationCod
204207
- `fastify.customOauth2.getAccessTokenFromAuthorizationCodeFlow`
205208
- `fastify.customOauth2.getNewAccessTokenUsingRefreshToken`
206209

207-
## Usage with Typescript
210+
## Usage with TypeScript
208211

209-
Type definitions are provided with package. Decoration are applied during runtime and are based on auth configuration name. One solution is leverage typescript declaration merging to add type-safe namespace.
212+
Type definitions are provided with the package. Decorations are applied during runtime and are based on auth configuration name. One solution is to leverage TypeScript declaration merging to add type-safe namespace.
210213

211214
In project declarations files .d.ts
212215

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"description": "Perform login using oauth2 protocol",
55
"main": "index.js",
66
"scripts": {
7+
"coverage": "npm run unit -- --cov --coverage-report=html",
78
"lint": "standard | snazzy",
8-
"unit": "tap test.js",
99
"test": "npm run lint && npm run unit && npm run test:typescript",
1010
"test:typescript": "tsd",
11-
"coverage": "npm run unit -- --cov --coverage-report=html"
11+
"unit": "tap test.js"
1212
},
1313
"repository": {
1414
"type": "git",

0 commit comments

Comments
 (0)