From 901bdc580f8de247956048799c4683311e3adfea Mon Sep 17 00:00:00 2001 From: Frazer Smith <43814140+Fdawgs@users.noreply.github.com> Date: Tue, 13 Apr 2021 12:35:31 +0100 Subject: [PATCH] chore: doc and ci updates (#57) --- .github/workflows/{nodejs.yml => ci.yml} | 30 ++++++++++++++---------- README.md | 21 ++++++++++------- 2 files changed, 30 insertions(+), 21 deletions(-) rename .github/workflows/{nodejs.yml => ci.yml} (52%) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/ci.yml similarity index 52% rename from .github/workflows/nodejs.yml rename to .github/workflows/ci.yml index 3cd27e5..539b3f6 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/ci.yml @@ -1,38 +1,44 @@ -name: Node CI - -on: [push, pull_request] +name: CI + +on: + push: + paths-ignore: + - 'docs/**' + - '*.md' + pull_request: + paths-ignore: + - 'docs/**' + - '*.md' jobs: test: - name: Test runs-on: ${{ matrix.os }} strategy: matrix: node-version: [10.x, 12.x, 14.x] - os: [ubuntu-latest, macOS-latest, windows-latest] + os: [macos-latest, ubuntu-latest, windows-latest] steps: - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} + - name: Use Node.js uses: actions/setup-node@v2.1.5 with: node-version: ${{ matrix.node-version }} - - name: Install + - name: Install Dependencies run: | - npm install + npm install --ignore-scripts - - name: Test + - name: Run Tests run: | - npm test + npm run test automerge: needs: test runs-on: ubuntu-latest steps: - uses: fastify/github-action-merge-dependabot@v2.0.0 - if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }} with: - github-token: ${{secrets.github_token}} + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 4617c82..398de8c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # fastify-sensible -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) ![Node CI](https://github.com/fastify/fastify-sensible/workflows/Node%20CI/badge.svg) +![CI](https://github.com/fastify/fastify-sensible/workflows/CI/badge.svg) +[![NPM version](https://img.shields.io/npm/v/fastify-sensible.svg?style=flat)](https://www.npmjs.com/package/fastify-sensible) +[![Known Vulnerabilities](https://snyk.io/test/github/fastify/fastify-sensible/badge.svg)](https://snyk.io/test/github/fastify/fastify-sensible) +[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/) Defaults for Fastify that everyone can agree on™.
This plugin adds some useful utilities to your Fastify instance, see the API section to learn more. @@ -9,7 +12,7 @@ Supports Fastify versions `3.x`. Please refer to [this branch](https://github.com/fastify/fastify-sensible/tree/2.x) and related versions for Fastify `2.x` compatibility. Please refer to [this branch](https://github.com/fastify/fastify-sensible/tree/1.x) and related versions for Fastify `1.x` compatibility. -*Why these APIs are here and not directly into core?
+*Why are these APIs here and not included with Fastify?
Because Fastify aims to be as small and focused as possible, every utility that is not essential should be shipped as standalone plugin.* ## Install @@ -97,7 +100,7 @@ var err = fastify.httpErrors.createError(404, 'This video does not exist!') ``` #### `reply.[httpError]` -The `reply` interface is decorated with all the functions declared above, use it is very easy: +The `reply` interface is decorated with all the functions declared above, using it is very easy: ```js fastify.get('/', (req, reply) => { reply.notFound() @@ -105,7 +108,7 @@ fastify.get('/', (req, reply) => { ``` #### `reply.vary` -The `reply` interface is decorated with [`jshttp/vary`](https://github.com/jshttp/vary), the API is the same, but you don't need to pass the res object. +The `reply` interface is decorated with [`jshttp/vary`](https://github.com/jshttp/vary), the API is the same, but you do not need to pass the res object. ```js fastify.get('/', (req, reply) => { reply.vary('Accept') @@ -114,7 +117,7 @@ fastify.get('/', (req, reply) => { ``` #### `request.forwarded` -The `request` interface is decorated with [`jshttp/forwarded`](https://github.com/jshttp/forwarded), the API is the same, but you don't need to pass the request object. +The `request` interface is decorated with [`jshttp/forwarded`](https://github.com/jshttp/forwarded), the API is the same, but you do not need to pass the request object: ```js fastify.get('/', (req, reply) => { reply.send(req.forwarded()) @@ -122,7 +125,7 @@ fastify.get('/', (req, reply) => { ``` #### `request.is` -The `request` interface is decorated with [`jshttp/type-is`](https://github.com/jshttp/type-is), the API is the same, but you don't need to pass the request object. +The `request` interface is decorated with [`jshttp/type-is`](https://github.com/jshttp/type-is), the API is the same, but you do not need to pass the request object: ```js fastify.get('/', (req, reply) => { reply.send(req.is(['html', 'json'])) @@ -130,7 +133,7 @@ fastify.get('/', (req, reply) => { ``` #### `assert` -Verify if a given condition is true, if not it throws the specified http error.
Very useful if you work with *async* routes. +Verify if a given condition is true, if not it throws the specified http error.
Very useful if you work with *async* routes: ```js // the custom message is optional fastify.assert( @@ -147,7 +150,7 @@ The `assert` API exposes also the following methods: - fastify.assert.notDeepEqual() #### `to` -Async await wrapper for easy error handling without try-catch, inspired by [`await-to-js`](https://github.com/scopsy/await-to-js) +Async await wrapper for easy error handling without try-catch, inspired by [`await-to-js`](https://github.com/scopsy/await-to-js): ```js const [err, user] = await fastify.to( @@ -156,7 +159,7 @@ const [err, user] = await fastify.to( ``` #### Custom error handler -This plugins also adds a custom error handler which hides the error message in case of `500` errors that are being generated by throwed errors, instead it returns `Something went wrong`.
+This plugins also adds a custom error handler, which hides the error message in case of `500` errors that are being generated by throwed errors, instead it returns `Something went wrong`.
This is especially useful if you are using *async* routes, where every uncaught error will be sent back to the user *(but do not worry, the original error message is logged as error in any case)*. If needed, it can be disabled by setting the option `errorHandler` to `false`.