Skip to content

Commit ef966b6

Browse files
Merge branch 'main' into production
2 parents bb9a686 + e40b1a1 commit ef966b6

File tree

8 files changed

+464
-318
lines changed

8 files changed

+464
-318
lines changed

docs/.vuepress/config.js

Lines changed: 250 additions & 149 deletions
Large diffs are not rendered by default.

docs/developer-docs/latest/developer-resources/plugin-api-reference/server.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ module.exports = {
247247
```js
248248
// path: ./controllers/controller-a.js
249249

250-
module.exports = {
250+
module.exports = ({ strapi }) => ({
251251
doSomething(ctx) {
252252
ctx.body = { message: 'HelloWorld' };
253253
},
254-
};
254+
});
255255
```
256256

257257
### Services

docs/developer-docs/latest/development/backend-customization/models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ Lifecycle hooks are functions that take an `event` parameter, an object with the
537537
| Key | Type | Description |
538538
| -------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
539539
| `action` | String | Lifecycle event that has been triggered (see [list](#available-lifecycle-events)) |
540-
| `model` | String | Model name |
540+
| `model` | Object | Model object |
541541
| `em` | EntityManagerObject | EntityManager | |
542542
| `params` | Object | Accepts the following parameters:<ul><li>`data`</li><li>`select`</li><li>`where`</li><li>`orderBy`</li><li>`limit`</li><li>`offset`</li><li>`populate`</li></ul> |
543543
| `result` | Object | _Optional, only available with `afterXXX` events_<br><br>Contains the result of the action. |

docs/developer-docs/latest/plugins/email.md

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const emailTemplate = {
5252
<p>Your account is now linked with: <%= user.email %>.<p>`,
5353
};
5454

55-
await strapi.plugins.email.services.email.sendTemplatedEmail(
55+
await strapi.plugins['email'].services.email.sendTemplatedEmail(
5656
{
5757
to: user.email,
5858
// from: is not specified, so it's the defaultFrom that will be used instead
@@ -68,68 +68,68 @@ await strapi.plugins.email.services.email.sendTemplatedEmail(
6868

6969
By default Strapi provides a local email system ([sendmail](https://www.npmjs.com/package/sendmail)). If you want to use a third party to send emails, you need to install the correct provider module. Otherwise you can skip this part and continue to configure your provider.
7070

71-
You can check all the available providers developed by the community on npmjs.org - [Providers list](https://www.npmjs.com/search?q=strapi-provider-email-)
71+
Below are the providers maintained by the Strapi team:
7272

73-
To install a new provider run:
73+
- [Amazon SES](https://www.npmjs.com/package/@strapi/provider-email-amazon-ses)
74+
- [Mailgun](https://www.npmjs.com/package/@strapi/provider-email-mailgun)
75+
- [Nodemailer](https://www.npmjs.com/package/@strapi/provider-email-nodemailer)
76+
- [SendGrid](https://www.npmjs.com/package/@strapi/provider-email-sendgrid)
77+
- [Sendmail](https://www.npmjs.com/package/@strapi/provider-email-sendmail)
7478

79+
You can also find additional community maintained providers on [NPM](https://www.npmjs.com/).
7580

81+
To install a new provider run:
7682

7783
<code-group>
7884

7985
<code-block title="NPM">
8086
```sh
81-
npm install strapi-provider-email-sendgrid --save
87+
npm install @strapi/provider-email-sendgrid --save
8288
```
8389
</code-block>
8490

8591
<code-block title="YARN">
8692
```sh
87-
yarn add strapi-provider-email-sendgrid --save
93+
yarn add @strapi/provider-email-sendgrid --save
8894
```
8995
</code-block>
9096

9197
</code-group>
9298

93-
#### Using scoped packages as providers
94-
95-
If your package name is [scoped](https://docs.npmjs.com/about-scopes) (for example `@username/strapi-provider-email-gmail-oauth2`) you need to take an extra step by aliasing it in `package.json`. Go to the `dependencies` section and change the provider line to look like this:
96-
97-
`"strapi-provider-email-gmail-oauth2": "npm:@username/[email protected]"`
98-
99-
The string after the last `@` represents your desired [semver](https://docs.npmjs.com/about-semantic-versioning) version range.
100-
10199
### Configure your provider
102100

103-
After installing your provider you will need to add some settings in `config/plugins.js`. If this file doesn't exists, you'll need to create it. Check the README of each provider to know what configuration settings the provider needs.
101+
After installing your provider you will need to add some settings in `./config/plugins.js`. If this file doesn't exists, you'll need to create it. Check the README of each provider to know what configuration settings the provider needs.
104102

105103
::: tip
106104
Make sure you have the correct spelling of the configuration filename, it is written in plural (with a trailing 's'): `plugins.js`.
107105
:::
108106

109-
Here is an example of a configuration made for the provider [strapi-provider-email-sendgrid](https://www.npmjs.com/package/strapi-provider-email-sendgrid).
107+
Here is an example of a configuration made for the provider [@strapi/provider-email-sendgrid](https://www.npmjs.com/package/strapi-provider-email-sendgrid).
110108

111109
**Path —** `./config/plugins.js`.
112110

113111
```js
114112
module.exports = ({ env }) => ({
115113
// ...
116114
email: {
117-
provider: 'sendgrid',
118-
providerOptions: {
119-
apiKey: env('SENDGRID_API_KEY'),
120-
},
121-
settings: {
122-
defaultFrom: '[email protected]',
123-
defaultReplyTo: '[email protected]',
124-
testAddress: '[email protected]',
115+
config: {
116+
provider: 'sendgrid',
117+
providerOptions: {
118+
apiKey: env('SENDGRID_API_KEY'),
119+
},
120+
settings: {
121+
defaultFrom: '[email protected]',
122+
defaultReplyTo: '[email protected]',
123+
testAddress: '[email protected]',
124+
},
125125
},
126126
},
127127
// ...
128128
});
129129
```
130130

131131
::: tip
132-
If you're using a different provider depending on your environment, you can specify the correct configuration in `config/env/${yourEnvironment}/plugins.js`. More info here: [Environments](http://localhost:8080/documentation/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.md)
132+
If you're using a different provider depending on your environment, you can specify the correct configuration in `./config/env/${yourEnvironment}/plugins.js`. More info here: [Environments](/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.md)
133133
:::
134134

135135
::: tip
@@ -143,8 +143,6 @@ More info here: [Configure templates Locally](/user-docs/latest/settings/configu
143143

144144
## Create new provider
145145

146-
If you want to create your own, make sure the name starts with `strapi-provider-email-` (duplicating an existing one will be easier) and customize the `send` function.
147-
148146
Default template
149147

150148
```js
@@ -157,6 +155,17 @@ module.exports = {
157155
};
158156
```
159157

158+
It is important that your provider's `package.json` includes the following object:
159+
160+
```json
161+
{
162+
// ...
163+
"strapi": {
164+
"isProvider": true
165+
}
166+
}
167+
```
168+
160169
In the `send` function you will have access to:
161170

162171
- `providerOptions` that contains configurations written in `plugins.js`
@@ -170,7 +179,7 @@ To use it you will have to publish it on **npm**.
170179
If you want to create your own provider without publishing it on **npm** you can follow these steps:
171180

172181
- Create a `providers` folder in your application.
173-
- Create your provider as explained in the documentation eg. `./providers/strapi-provider-email-[...]/...`
182+
- Create your provider (e.g. `./providers/strapi-provider-email-[...]/...`)
174183
- 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.
175184

176185
```json

0 commit comments

Comments
 (0)