Fix typo PR feedback

This commit is contained in:
Jim LAURIE 2019-10-24 15:08:42 +02:00
parent 7e09cc0661
commit 3b0c77b5cc
7 changed files with 29 additions and 29 deletions

View File

@ -127,7 +127,7 @@ module.exports = {
'/3.0.0-beta.x/guides/databases',
'/3.0.0-beta.x/guides/deployment',
'/3.0.0-beta.x/guides/jwt-validation',
'/3.0.0-beta.x/guides/error-handling',
'/3.0.0-beta.x/guides/error-catching',
'/3.0.0-beta.x/guides/webhooks',
],
},

View File

@ -3,7 +3,7 @@
See the [parameters' concepts](../concepts/parameters.md) for details.
::: warning
By default, the filters can only be used from `find` endpoints generated by the Content Type Builder and the [CLI](../cli/CLI.md). If you need to implement a filters system somewhere else, read the [programmatic usage](../concepts/parameters.md) section.
By default, the filters can only be used from `find` endpoints generated by the Content Type Builder and the [CLI](../cli/CLI.md). If you need to implement a filter system somewhere else, read the [programmatic usage](../concepts/parameters.md) section.
:::
## Available operators

View File

@ -6,7 +6,7 @@ Welcome to the open source [headless CMS](https://strapi.io) developers love.
### 👋 Welcome onboard!
Users love Strapi because it is open source, MIT licensed, fully customizable and based on Node.js. Strapi lets you manage your content and distribute it anywhere. Strapi allows you to securely and privately serve your database of choice from your hosting and server of choice.
Users love Strapi because it is open source, MIT licensed, fully customizable and based on Node.js. Strapi lets you manage your content and distribute it anywhere. Strapi allows you to securely and privately serve your database from your hosting and server of choice.
### Get Started

View File

@ -1,6 +1,6 @@
# Error handling
# Error catching
In this guide we will see how you can handle errors to send it on the Application Monitoring / Error Tracking Software you want.
In this guide we will see how you can catch errors and send them to the Application Monitoring / Error Tracking Software you want.
::: note
In this example we will use [Sentry](https://sentry.io).
@ -8,7 +8,7 @@ In this example we will use [Sentry](https://sentry.io).
## Create a middleware
To handle errors, we will have to use a [middleware](../concepts/middlewares.md) that will catch errors and send them to Sentry.
A [middleware](../concepts/middlewares.md) will be used in order to catch the errors which will then be sent to Sentry.
- Create a `./middlewares/sentry/index.js` file.
@ -28,15 +28,15 @@ module.exports = strapi => {
## Handle errors
Here is the [Node.js client documentation](https://docs.sentry.io/clients/node/)
Here is the [Node.js client documentation](https://docs.sentry.io/platforms/node/)
- Now add the logic that will catch errors.
**Path —** `./middlewares/sentry/index.js`
```js
var Raven = require('raven');
Raven.config('https://<key>@sentry.io/<project>').install();
const Sentry = require('@sentry/node');
Sentry.init({ dsn: 'https://<key>@sentry.io/<project>' });
module.exports = strapi => {
return {
@ -45,7 +45,7 @@ module.exports = strapi => {
try {
await next();
} catch (error) {
Raven.captureException(error);
Sentry.captureException(error);
throw error;
}
});
@ -55,12 +55,12 @@ module.exports = strapi => {
```
::: warning
It's important to `throw(error);` to not stop the middleware stack. If you don't do that, **Boom** will not structure errors messages.
It's important to call `throw(error);` to avoid stopping the middleware stack. If you don't re-throw the error, it won't be handled by the Strapi's error formatter and the api will never respond to the client.
:::
## Configure the middleware
You will have to order this middleware at the end of the middleware stack.
Make sure your middleware is added at the end of the middleware stack.
**Path —** `./config/middleware.json`
@ -76,7 +76,7 @@ You will have to order this middleware at the end of the middleware stack.
}
```
And fianlly you have to enable the middleware.
And finally you have to enable the middleware.
**Path —** `./config/environments/**/middleware.json`

View File

@ -1,8 +1,8 @@
# JWT validation
In this guide we will see how validate a JWT via another service.
In this guide we will see how to validate a `JWT` (JSON Web Token) with a third party service.
When you signin with the authentication route `POST /auth/local`, Strapi generate a `JWT` that let your users request your API as an authenticated user.
When you sign in with the authentication route `POST /auth/local`, Strapi generates a `JWT` which lets your users request your API as an authenticated one.
```json
{
@ -15,17 +15,17 @@ When you signin with the authentication route `POST /auth/local`, Strapi generat
}
```
These users are managed in the application database and can be managed via the admin dashboard.
These users are managed in the application's database and can be managed via the admin dashboard.
We can now imagine you have a `JWT` that come from [Auth0](https://auth0.com) and you want to make sure the `JWT` is correct and allow this user to use the Strapi API endpoints.
We can now imagine you have a `JWT` that comes from [Auth0](https://auth0.com) and you want to make sure the `JWT` is correct before allowing the user to use the Strapi API endpoints.
## Customise the JWT validation function
## Customize the JWT validation function
We have to use the [customization concept](../concepts/customization.md) to update the function that validate the `JWT`. This feature is powered by the **Users & Permissions** plugin.
We have to use the [customization concept](../concepts/customization.md) to update the function that validates the `JWT`. This feature is powered by the **Users & Permissions** plugin.
Here is the file we will have to customize: [permission.js](https://github.com/strapi/strapi/blob/master/packages/strapi-plugin-users-permissions/config/policies/permissions.js)
- We have now to create a file that follow this path `./extensions/users-permissions/config/policies/permissions.js`.
- We have to create a file that follows this path `./extensions/users-permissions/config/policies/permissions.js`.
- You will have to add in this new file, the same content of the original one.
Now we are ready to create our custom validation code.
@ -55,11 +55,11 @@ module.exports = async (ctx, next) => {
}
```
The `jwt.getToken` will throw and error it the token don't come from Strapi. So if it's not a Strapi `JWT` token, lets test if it's an Auth0 token.
The `jwt.getToken` will throw an error if the token doesn't come from Strapi. So if it's not a Strapi `JWT` token, let's test if it's an Auth0 one.
We will have to write our validation code before throwing an error.
By using the [Auth0 get user profile](https://auth0.com/docs/api/authentication?http#get-user-info) documentation, I will verify a valid user match with the current `JWT`
By using the [Auth0 get user profile](https://auth0.com/docs/api/authentication?http#get-user-info) documentation, you will verify a valid user matches with the current `JWT`
```js
const _ = require('lodash');
@ -99,5 +99,5 @@ module.exports = async (ctx, next) => {
```
::: warning
In the code example we use `axios` you will have to install the dependence to make it works or use and other library to request Auth0 API.
In the code example we use `axios` you will have to install the dependency to make it work. You can choose another library if you prefer.
:::

View File

@ -93,10 +93,10 @@ To use it you will have to publish it on **npm**.
### Create a local provider
If you want create your own provider without publishing it on **npm** you can follow these following steps:
If you want to create your own provider without publishing it on **npm** you can follow these steps:
- You create a `providers` folder in your application.
- Create your provider as explain in the documentation eg. `./providers/strapi-provider-email-[...]/...`
- Create a `providers` folder in your application.
- Create your provider as explained in the documentation eg. `./providers/strapi-provider-email-[...]/...`
- Then update your `package.json` to link your `strapi-provider-email-[...]` dependency to the [local path](https://docs.npmjs.com/files/package.json#local-paths) of your new provider.
```json

View File

@ -298,10 +298,10 @@ To use it you will have to publish it on **npm**.
### Create a local provider
If you want create your own provider without publishing it on **npm** you can follow these following steps:
If you want create your own provider without publishing it on **npm** you can follow these steps:
- You create a `providers` folder in your application.
- Create your provider as explain in the documentation eg. `./providers/strapi-provider-upload-[...]/...`
- Create a `providers` folder in your application.
- Create your provider as explained in the documentation eg. `./providers/strapi-provider-upload-[...]/...`
- Then update your `package.json` to link your `strapi-provider-upload-[...]` dependency to the [local path](https://docs.npmjs.com/files/package.json#local-paths) of your new provider.
```json