mirror of
https://github.com/strapi/strapi.git
synced 2025-10-10 15:43:41 +00:00
replaced blockquotes with proper note containers
This commit is contained in:
parent
f52ab10de0
commit
6ea86fc9ae
@ -9,6 +9,7 @@ module.exports = {
|
||||
md
|
||||
.use(require('markdown-it-decorate'))
|
||||
.use(...createContainer('intro'))
|
||||
.use(...createContainer('note'))
|
||||
}
|
||||
},
|
||||
title: 'Strapi Docs',
|
||||
|
@ -2,7 +2,7 @@
|
||||
.custom-block-title
|
||||
font-weight 600
|
||||
margin-bottom -0.4rem
|
||||
&.tip, &.warning, &.danger
|
||||
&.tip, &.warning, &.danger, &.note
|
||||
padding .1rem 1.5rem
|
||||
border-left-width .5rem
|
||||
border-left-style solid
|
||||
@ -10,6 +10,9 @@
|
||||
&.tip
|
||||
background-color #f3f5f7
|
||||
border-color #42b983
|
||||
&.note
|
||||
background-color #f3f5f7
|
||||
border-color $accentColor
|
||||
&.warning
|
||||
background-color rgba(255,229,100,.3)
|
||||
border-color darken(#ffe564, 35%)
|
||||
|
@ -76,7 +76,9 @@ Run `npm start` from the `./admin` folder. That's all.
|
||||
|
||||
You should be able to see the admin at [http://localhost:4000/admin](http://localhost:4000/admin).
|
||||
|
||||
> Note: In development, all the plugins of your app are mounted in the same build as the administration panel.
|
||||
::: note
|
||||
In development, all the plugins of your app are mounted in the same build as the administration panel.
|
||||
:::
|
||||
|
||||
### Colors
|
||||
|
||||
@ -95,7 +97,9 @@ Fonts can also be overridden:
|
||||
|
||||
To change the top-left displayed admin panel's logo, replace the image located at `./admin/admin/src/assets/images/logo-strapi.png`.
|
||||
|
||||
Note: make sure the size of your image is the same as the existing one (434px x 120px).
|
||||
::: note
|
||||
make sure the size of your image is the same as the existing one (434px x 120px).
|
||||
:::
|
||||
|
||||
***
|
||||
|
||||
@ -109,7 +113,11 @@ npm run setup
|
||||
|
||||
This will replace the folder's content located at `./admin/admin/build`. Visit http://localhost:1337/admin/ to make sure your updates have been taken in account.
|
||||
|
||||
After you have built the admininistration you can now create a new project to develop your API with the changes implemented. **Note:** You should now create a project without `--dev`
|
||||
After you have built the admininistration you can now create a new project to develop your API with the changes implemented.
|
||||
|
||||
::: note
|
||||
You should now create a project without `--dev`
|
||||
:::
|
||||
|
||||
***
|
||||
|
||||
@ -178,7 +186,9 @@ It's very common to deploy the front-end and the back-end on different servers.
|
||||
|
||||
The administration URL will be http://yourfrontend.com and every request from the panel will hit the backend at http://yourbackend.com. The plugins will be injected through the `origin` (means the API itself). In other words, the plugins URLs will be `http://yourbackend.com/dashboard/content-manager/main.js`.
|
||||
|
||||
> Note: How it is possible? The API (the Strapi server) owns the plugin and these plugins are exposed through `http://yourbackend.com/admin/**/main.js`
|
||||
::: note
|
||||
How it is possible? The API (the Strapi server) owns the plugin and these plugins are exposed through `http://yourbackend.com/admin/**/main.js`
|
||||
:::
|
||||
|
||||
|
||||
The DOM should look like this:
|
||||
@ -198,7 +208,9 @@ The DOM should look like this:
|
||||
</html>
|
||||
```
|
||||
|
||||
> Note: The plugins are injected using the `./admin/admin/build/config/plugins.json`. To see the plugins URLs in the `index.html`, you need to launch the administration panel in the browser.
|
||||
::: note
|
||||
The plugins are injected using the `./admin/admin/build/config/plugins.json`. To see the plugins URLs in the `index.html`, you need to launch the administration panel in the browser.
|
||||
:::
|
||||
|
||||
#### Deploy the administration panel and the plugins on another server than the API
|
||||
|
||||
@ -275,5 +287,6 @@ The generated `index.html` will look like this:
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
> Note: The plugins are injected using the `./admin/admin/build/config/plugins.json`. To see the plugins URLs in the `index.html`, you need to launch the administration panel in the browser.
|
||||
::: note
|
||||
The plugins are injected using the `./admin/admin/build/config/plugins.json`. To see the plugins URLs in the `index.html`, you need to launch the administration panel in the browser.
|
||||
:::
|
||||
|
@ -58,7 +58,9 @@ The core of Strapi embraces a small list of middlewares for performances, securi
|
||||
- xframe
|
||||
- xss
|
||||
|
||||
> Note: The following middlewares cannot be disabled: responses, router, logger and boom.
|
||||
::: note
|
||||
The following middlewares cannot be disabled: responses, router, logger and boom.
|
||||
:::
|
||||
|
||||
## Structure
|
||||
|
||||
|
@ -21,7 +21,9 @@ Here is the list of the collected data and why we need them.
|
||||
|
||||
We are not collecting sensitive data such as databases configurations, environment or custom variables. The data are encrypted and anonymised.
|
||||
|
||||
> GDPR: The collected data are non-sensitive or personal data. We are compliant with the European recommendations (see our [Privacy Policy](https://strapi.io/privacy)).
|
||||
::: warning GDPR
|
||||
The collected data are non-sensitive or personal data. We are compliant with the European recommendations (see our [Privacy Policy](https://strapi.io/privacy)).
|
||||
:::
|
||||
|
||||
## Disable
|
||||
|
||||
|
@ -35,7 +35,9 @@ Returns the Koa instance.
|
||||
|
||||
Returns a `Promise`. When resolved, it means that the `./config/functions/bootstrap.js` has been executed. Otherwise, it throws an error.
|
||||
|
||||
> Note: You can also access to the bootstrap function through `strapi.config.functions.boostrap`.
|
||||
::: note
|
||||
You can also access to the bootstrap function through `strapi.config.functions.boostrap`.
|
||||
:::
|
||||
|
||||
## strapi.config
|
||||
|
||||
@ -45,7 +47,9 @@ Returns an object that represents the configurations of the project. Every JavaS
|
||||
|
||||
Returns an object of the controllers wich is available in the project. Every JavaScript file located in the `./api/**/controllers` folder will be parsed into the `strapi.controllers` object. Thanks to this object, you can access to every controller's actions everywhere in the project.
|
||||
|
||||
> Note: This object doesn't include the admin's controllers and plugin's controllers.
|
||||
::: note
|
||||
This object doesn't include the admin's controllers and plugin's controllers.
|
||||
:::
|
||||
|
||||
## strapi.hook
|
||||
|
||||
|
@ -55,7 +55,9 @@ options: [--tpl <name>|--plugin <name>]
|
||||
|
||||
Example: `strapi generate:api product --tpl bookshelf`
|
||||
|
||||
> Note: The first letter of the filename will be uppercased.
|
||||
::: note
|
||||
The first letter of the filename will be uppercased.
|
||||
:::
|
||||
|
||||
## strapi generate:controller
|
||||
Create a new controller
|
||||
@ -79,7 +81,9 @@ options: [--api <name>|--plugin <name>]
|
||||
- **strapi generate:controller <name> --plugin <plugin>**<br/>
|
||||
Generates an empty controller called **<name>** in the `./plugins/<plugin>/controllers` folder.
|
||||
|
||||
> Note: The first letter of the filename will be uppercased.
|
||||
::: note
|
||||
The first letter of the filename will be uppercased.
|
||||
:::
|
||||
|
||||
## strapi generate:model
|
||||
Create a new model
|
||||
@ -112,7 +116,9 @@ options: [--api <name>|--plugin <name>]
|
||||
- **strapi generate:model <name> --plugin <plugin>**<br/>
|
||||
Generates an empty model called **<name>** in the `./plugins/<plugin>/models` folder.
|
||||
|
||||
> Note: The first letter of the filename will be uppercased.
|
||||
::: note
|
||||
The first letter of the filename will be uppercased.
|
||||
:::
|
||||
|
||||
## strapi generate:service
|
||||
Create a new service
|
||||
@ -136,7 +142,9 @@ options: [--api <name>|--plugin <name>]
|
||||
- **strapi generate:service <name> --plugin <plugin>**<br/>
|
||||
Generates an empty service called **<name>** in the `./plugins/<plugin>/services` folder.
|
||||
|
||||
> Note: The first letter of the filename will be uppercased.
|
||||
::: note
|
||||
The first letter of the filename will be uppercased.
|
||||
:::
|
||||
|
||||
## strapi generate:policy
|
||||
Create a new policy
|
||||
@ -200,7 +208,9 @@ options: [--dev]
|
||||
> Checkout the [CONTRIBUTING guide](https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md) for more details about the local Strapi development workflow.
|
||||
|
||||
|
||||
> **Note: You have to restart the server to load the plugin into your project.**
|
||||
::: warning
|
||||
You have to restart the server to load the plugin into your project.
|
||||
:::
|
||||
|
||||
Please refer to the [plugins documentation](../plugin-development/quick-start.md) to know more.
|
||||
|
||||
|
@ -63,7 +63,9 @@ By default, your project's structure will look like this:
|
||||
- [`/public`](../concepts/concepts.html#public-assets): contains the file accessible to the outside world.
|
||||
|
||||
|
||||
> Tips: Inside the `/config` folder, every folder will be parsed and injected into the global object `strapi.config`. Let's say, you added a folder named `credentials` with two files `stripe.json` and `paypal.json` into it. The content of these files will be accessible through `strapi.config.credentials.stripe` and `strapi.config.credentials.paypal`.
|
||||
::: note
|
||||
Inside the `/config` folder, every folder will be parsed and injected into the global object `strapi.config`. Let's say, you added a folder named `credentials` with two files `stripe.json` and `paypal.json` into it. The content of these files will be accessible through `strapi.config.credentials.stripe` and `strapi.config.credentials.paypal`.
|
||||
:::
|
||||
|
||||
***
|
||||
|
||||
|
@ -95,7 +95,9 @@ Here are some use cases:
|
||||
|
||||
CRON tasks allow you to schedule jobs (arbitrary functions) for execution at specific dates, with optional recurrence rules. It only uses a single timer at any given time (rather than reevaluating upcoming jobs every second/minute).
|
||||
|
||||
> Note: Make sure the `enabled` cron config is set to `true` in your environment's variables.
|
||||
::: note
|
||||
Make sure the `enabled` cron config is set to `true` in your environment's variables.
|
||||
:::
|
||||
|
||||
The cron format consists of:
|
||||
|
||||
@ -153,7 +155,9 @@ Each JSON file located in the folder must have the name of its corresponding tra
|
||||
|
||||
Most of the application's configurations are defined by environment. It means that you can specify settings for each environment (`development`, `production`, `test`, etc.).
|
||||
|
||||
> Note: You can access the config of the current environment through `strapi.config.currentEnvironment`.
|
||||
::: note
|
||||
You can access the config of the current environment through `strapi.config.currentEnvironment`.
|
||||
:::
|
||||
|
||||
***
|
||||
|
||||
@ -278,7 +282,9 @@ Most of the application's configurations are defined by environment. It means th
|
||||
- `router`
|
||||
- `prefix` (string): API url prefix (eg. `/v1`).
|
||||
|
||||
> Note: The session doesn't work with `mongo` as a client. The package that we should use is broken for now.
|
||||
::: note
|
||||
The session doesn't work with `mongo` as a client. The package that we should use is broken for now.
|
||||
:::
|
||||
|
||||
***
|
||||
|
||||
@ -383,7 +389,9 @@ In any JSON configurations files in your project, you can inject dynamic values
|
||||
}
|
||||
```
|
||||
|
||||
> Note: You can't execute functions inside the curly braces. Only strings are allowed.
|
||||
::: note
|
||||
You can't execute functions inside the curly braces. Only strings are allowed.
|
||||
:::
|
||||
|
||||
***
|
||||
|
||||
|
@ -16,7 +16,9 @@ Time to install Strapi!
|
||||
npm install strapi@alpha -g
|
||||
```
|
||||
|
||||
Note: if you encounter npm permissions issues, [change the permissions to npm default directory](https://docs.npmjs.com/getting-started/fixing-npm-permissions#option-1-change-the-permission-to-npms-default-directory).
|
||||
::: note
|
||||
If you encounter npm permissions issues, [change the permissions to npm default directory](https://docs.npmjs.com/getting-started/fixing-npm-permissions#option-1-change-the-permission-to-npms-default-directory).
|
||||
:::
|
||||
|
||||
It takes about 20 seconds with a good Internet connection. You can take a coffee ☕️ if you have a slow one.
|
||||
|
||||
|
@ -3,21 +3,18 @@
|
||||
This section explains how to handle Strapi for the first time, ([check out our tutorial video](https://www.youtube.com/watch?v=yMl5IcFHA74)).
|
||||
|
||||
**Table of contents:**
|
||||
- [Create your first project](#create-your-first-project)
|
||||
- [Create your first API](#create-your-first-api)
|
||||
- [Content Type Builder plugin](#content-type-builder-plugin)
|
||||
- [Files structure](#files-structure)
|
||||
- [Manage your data](#manage-your-data)
|
||||
- [Content Manager Plugin](#content-manager-plugin)
|
||||
- [Create a product](#create-a-product)
|
||||
- [Edit a product](#edit-a-product)
|
||||
- [Delete a product](#delete-a-product)
|
||||
- [Consume your API](#consume-your-api)
|
||||
- [List entries](#list-entries)
|
||||
- [Get a specific entry](#get-a-specific-entry)
|
||||
- [Create data (POST)](#create-data-post)
|
||||
- [Update data (PUT)](#update-data-put)
|
||||
- [Delete data (DELETE)](#delete-data-delete)
|
||||
- [Quick start](#quick-start)
|
||||
- [Create your first project](#create-your-first-project)
|
||||
- [Create your first user](#create-your-first-user)
|
||||
- [Create your first API](#create-your-first-api)
|
||||
- [Files structure](#files-structure)
|
||||
- [Manage your data](#manage-your-data)
|
||||
- [Consume your API](#consume-your-api)
|
||||
- [List entries (GET)](#list-entries-get)
|
||||
- [Get a specific entry (GET)](#get-a-specific-entry-get)
|
||||
- [Create data (POST)](#create-data-post)
|
||||
- [Update data (PUT)](#update-data-put)
|
||||
- [Delete data (DELETE)](#delete-data-delete)
|
||||
|
||||
***
|
||||
|
||||
@ -92,7 +89,9 @@ At this point, your application is empty. To create your first API is to use the
|
||||
**#4 —** Save. That's it!
|
||||
|
||||
|
||||
> Note: See the [CLI documentation](../cli/CLI.md#strapi-generateapi) for more information on how to do it the hacker way.
|
||||
::: note
|
||||
See the [CLI documentation](../cli/CLI.md#strapi-generateapi) for more information on how to do it the hacker way.
|
||||
:::
|
||||
|
||||
### Files structure
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
# Authentication
|
||||
|
||||
> ⚠️ This feature requires the Users & Permissions plugin (installed by default).
|
||||
::: warning
|
||||
This feature requires the Users & Permissions plugin (installed by default).
|
||||
:::
|
||||
|
||||
## Register a new user
|
||||
|
||||
|
@ -39,4 +39,6 @@ module.exports = {
|
||||
};
|
||||
```
|
||||
|
||||
> Note: A route handler can only access the controllers defined in the `./api/**/controllers` folders.
|
||||
::: note
|
||||
A route handler can only access the controllers defined in the `./api/**/controllers` folders.
|
||||
:::
|
||||
|
@ -29,7 +29,9 @@ cd /path/to/the/project
|
||||
npm run setup
|
||||
```
|
||||
|
||||
> Note: To display the build logs use the --debug option `npm run setup --debug`.
|
||||
::: note
|
||||
To display the build logs use the --debug option `npm run setup --debug`.
|
||||
:::
|
||||
|
||||
#### #3 - Launch the server
|
||||
|
||||
@ -39,7 +41,9 @@ Run the server with the `production` settings.
|
||||
NODE_ENV=production npm start
|
||||
```
|
||||
|
||||
> We highly recommend to use [pm2](https://github.com/Unitech/pm2/) to manage your process.
|
||||
::: warning
|
||||
We highly recommend to use [pm2](https://github.com/Unitech/pm2/) to manage your process.
|
||||
:::
|
||||
|
||||
### Advanced configurations
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
# Email
|
||||
|
||||
> ⚠️ This feature requires the Email plugin (installed by default).
|
||||
::: warning
|
||||
This feature requires the Email plugin (installed by default).
|
||||
:::
|
||||
|
||||
Thanks to the plugin `Email`, you can send email on your server or externals providers such as Sendgrid.
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
See the [filters' concepts](../concepts/concepts.md#filters) for details.
|
||||
|
||||
::: tip Note
|
||||
::: note
|
||||
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](#programmatic-usage) section.
|
||||
:::
|
||||
|
||||
@ -76,7 +76,9 @@ Requests system can be implemented in custom code sections.
|
||||
|
||||
To extract the filters from an JavaScript object or a request, you need to call the [`strapi.utils.models.convertParams` helper](../api-reference/reference.md#strapiutils).
|
||||
|
||||
> Note: The returned objects is formatted according to the ORM used by the model.
|
||||
::: note
|
||||
The returned objects is formatted according to the ORM used by the model.
|
||||
:::
|
||||
|
||||
#### Example
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
# GraphQL
|
||||
|
||||
> ⚠️ This feature requires the GraphQL plugin (not installed by default).
|
||||
::: warning
|
||||
This feature requires the GraphQL plugin (not installed by default).
|
||||
:::
|
||||
|
||||
## Usage
|
||||
|
||||
@ -364,7 +366,9 @@ module.exports = {
|
||||
|
||||
Edit the `definition` attribute in one of the `schema.graphql` files of your project by using the GraphQL Type language string.
|
||||
|
||||
> Note: The easiest way is to create a new model using the CLI `strapi generate:model category --api post`, so you don't need to customise anything.
|
||||
::: note
|
||||
The easiest way is to create a new model using the CLI `strapi generate:model category --api post`, so you don't need to customise anything.
|
||||
:::
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
@ -507,7 +511,9 @@ module.exports = {
|
||||
|
||||
In this example, the policy `isAuthenticated` located in `./plugins/users-permissions/config/policies/isAuthenticated.js` will be executed first. Then, the `isOwner` policy located in the `Post` API `./api/post/config/policies/isOwner.js`. Next, it will execute the `logging` policy located in `./config/policies/logging.js`. Finally, the resolver will be executed.
|
||||
|
||||
> Note: There is no custom resolver in that case, so it will execute the default resolver (Post.find) provided by the Shadow CRUD feature.
|
||||
::: note
|
||||
There is no custom resolver in that case, so it will execute the default resolver (Post.find) provided by the Shadow CRUD feature.
|
||||
:::
|
||||
|
||||
### Link a query to a controller action
|
||||
|
||||
@ -528,7 +534,9 @@ module.exports = {
|
||||
|
||||
In this example, it will execute the `findByAuthor` action of the `Post` controller. It also means that the resolver will apply on the `posts` query the permissions defined on the `findByAuthor` action (through the administration panel).
|
||||
|
||||
> Note: The `obj` parameter is available via `ctx.params` and the `options` are available via `ctx.query` in the controller's action.
|
||||
::: note
|
||||
The `obj` parameter is available via `ctx.params` and the `options` are available via `ctx.query` in the controller's action.
|
||||
:::
|
||||
|
||||
### Define a custom resolver
|
||||
|
||||
@ -606,7 +614,9 @@ The type name is the global ID of the model. You can find the global ID of a mod
|
||||
|
||||
We recommend to put the field description and deprecated reason in the model. Right now, the GraphQL plugin is the only which uses these fields. Another plugin could use this description in the future as well. However, sometimes you don't have the choice, especially when you're defining a custom type.
|
||||
|
||||
> Note: It's not a bad practice to put the description and deprecated attribute in the `schema.graphql`, though.
|
||||
::: note
|
||||
It's not a bad practice to put the description and deprecated attribute in the `schema.graphql`, though.
|
||||
:::
|
||||
|
||||
**Why are the "createdAt" and "updatedAt" field added to my type?**
|
||||
|
||||
|
@ -3,7 +3,9 @@
|
||||
See the [models' concepts](../concepts/concepts.md#models) for details.
|
||||
|
||||
## How to create a model?
|
||||
> Note: If you are just starting out it is very convenient to generate some models with the Content Type Builder, directly in the admin interface. You can then review the generated model mappings on the code level. The UI takes over a lot of validation tasks and gives you a fast feeling for available features.
|
||||
::: note
|
||||
If you are just starting out it is very convenient to generate some models with the Content Type Builder, directly in the admin interface. You can then review the generated model mappings on the code level. The UI takes over a lot of validation tasks and gives you a fast feeling for available features.
|
||||
:::
|
||||
|
||||
Use the CLI, and run the following command `strapi generate:model user firstname:string lastname:string`. Read the [CLI documentation](../cli/CLI.md) for more informations.
|
||||
|
||||
@ -11,7 +13,9 @@ This will create two files located at `./api/user/models`:
|
||||
- `User.settings.json`: contains the list of attributes and settings. The JSON format makes the file easily editable.
|
||||
- `User.js`: imports `User.settings.json` and extends it with additional settings and lifecycle callbacks.
|
||||
|
||||
> Note: when you create a new API using the CLI (`strapi generate:api <name>`), a model is automatically created.
|
||||
::: note
|
||||
when you create a new API using the CLI (`strapi generate:api <name>`), a model is automatically created.
|
||||
:::
|
||||
|
||||
## Model Information
|
||||
The info key on the model-json states information about the model. This information is used in the admin interface, when showing the model.
|
||||
@ -291,7 +295,9 @@ A `product` can be related to many `categories`, so a `category` can have many `
|
||||
}
|
||||
```
|
||||
|
||||
> Note: The `dominant` key allows you to define in which table/collection (only for NoSQL databases) should be stored the array that defines the relationship. Because there is no join table in NoSQL, this key is required for NoSQL databases (ex: MongoDB).
|
||||
::: note
|
||||
The `dominant` key allows you to define in which table/collection (only for NoSQL databases) should be stored the array that defines the relationship. Because there is no join table in NoSQL, this key is required for NoSQL databases (ex: MongoDB).
|
||||
:::
|
||||
|
||||
**Path —** `./api/category/models/Category.settings.json`.
|
||||
```json
|
||||
@ -571,7 +577,9 @@ CREATE TABLE `image` (
|
||||
)
|
||||
```
|
||||
|
||||
> Note: If you've overrided the default table name given by Strapi by using the `collectionName` attribute. Use the value set in the `collectionName` to name the table.
|
||||
::: note
|
||||
If you've overrided the default table name given by Strapi by using the `collectionName` attribute. Use the value set in the `collectionName` to name the table.
|
||||
:::
|
||||
|
||||
The second table will allow us to associate one or many others entries to the `Image` model. The name of the table is the same as the previous one with the suffix `_morph`.
|
||||
```
|
||||
@ -693,4 +701,6 @@ Additional settings can be set on models:
|
||||
|
||||
In this example, the model `User` will be accessible through the `Users` global variable. The data will be stored in the `Users_v1` collection or table and the model will use the `mongo` connection defined in `./config/environments/**/database.json`
|
||||
|
||||
> Note: The `connection` value can be changed whenever you want, but you should be aware that there is no automatic data migration process. Also if the new connection doesn't use the same ORM you will have to rewrite your queries.
|
||||
::: note
|
||||
The `connection` value can be changed whenever you want, but you should be aware that there is no automatic data migration process. Also if the new connection doesn't use the same ORM you will have to rewrite your queries.
|
||||
:::
|
||||
|
@ -22,7 +22,9 @@ module.exports = async (ctx, next) => {
|
||||
|
||||
In this example, we are verifying that a session is open. If it is the case, we call the `next()` method that will execute the next policy or controller's action. Otherwise, a 401 error is returned.
|
||||
|
||||
> Note: You can access to any controllers, services or models thanks to the global variable `strapi` in a policy.
|
||||
::: note
|
||||
You can access to any controllers, services or models thanks to the global variable `strapi` in a policy.
|
||||
:::
|
||||
|
||||
## Usage
|
||||
|
||||
@ -54,7 +56,9 @@ The global policies can be associated to any routes in your project.
|
||||
|
||||
Before executing the `find` action in the `Car.js` controller, the global policy `isAuthenticated` located in `./config/policies/isAuthenticated.js` will be called.
|
||||
|
||||
> Note: You can put as much policy you want in this array. However be careful about the performance impact.
|
||||
::: note
|
||||
You can put as much policy you want in this array. However be careful about the performance impact.
|
||||
:::
|
||||
|
||||
### Plugins policies
|
||||
|
||||
@ -116,7 +120,9 @@ module.exports = async (ctx, next) => {
|
||||
|
||||
The policy `isAdmin` located in `./api/car/config/policies/isAdmin.js` will be executed before the `find` action in the `Car.js` controller.
|
||||
|
||||
> Note: The policy `isAdmin` can only be applied to the routes defined in the `/api/car` folder.
|
||||
::: note
|
||||
The policy `isAdmin` can only be applied to the routes defined in the `/api/car` folder.
|
||||
:::
|
||||
|
||||
## Advanced usage
|
||||
|
||||
|
@ -8,10 +8,12 @@ Because an API may need to serve static assets, every new Strapi project include
|
||||
|
||||
An image named `company-logo.png` in `./public/` is accessible through `/company-logo.png` URL.
|
||||
|
||||
> Note: `index.html` files are served if the request corresponds to a folder name (`/pictures` url will try to serve `public/pictures/index.html` file).
|
||||
|
||||
|
||||
> Warning bis: The dotfiles are not exposed. It means that every files with the names start by `.` such as `.htaccess` or `.gitignore` are not served.
|
||||
::: note
|
||||
`index.html` files are served if the request corresponds to a folder name (`/pictures` url will try to serve `public/pictures/index.html` file).
|
||||
:::
|
||||
|
||||
::: warning
|
||||
The dotfiles are not exposed. It means that every files with the names start by `.` such as `.htaccess` or `.gitignore` are not served.
|
||||
:::
|
||||
|
||||
Refer to the [public assets configurations](../configurations/configurations.md#Application) for more informations.
|
||||
|
@ -221,9 +221,11 @@ ctx.type = '.png';
|
||||
ctx.type = 'png';
|
||||
```
|
||||
|
||||
Note: when appropriate a `charset` is selected for you, for
|
||||
::: note
|
||||
when appropriate a `charset` is selected for you, for
|
||||
example `response.type = 'html'` will default to "utf-8". If you need to overwrite `charset`,
|
||||
use `ctx.set('Content-Type', 'text/html')` to set response header field to value directly.
|
||||
:::
|
||||
|
||||
#### response.is(types...)
|
||||
|
||||
@ -534,9 +536,11 @@ ctx.type = '.png';
|
||||
ctx.type = 'png';
|
||||
```
|
||||
|
||||
Note: when appropriate a `charset` is selected for you, for
|
||||
::: note
|
||||
when appropriate a `charset` is selected for you, for
|
||||
example `response.type = 'html'` will default to "utf-8". If you need to overwrite `charset`,
|
||||
use `ctx.set('Content-Type', 'text/html')` to set response header field to value directly.
|
||||
:::
|
||||
|
||||
#### response.is(types...)
|
||||
|
||||
@ -635,7 +639,9 @@ Strapi integrates [Boom](https://github.com/hapijs/boom): a set of utilities for
|
||||
|
||||
You can also override responses based on them status. Please read the [configuration responses](../configurations/configurations.md#responses) for that.
|
||||
|
||||
> Note: Every Boom's functions is delegated to the context. It means that `ctx.notFound` is a shortcut to `ctx.response.notFound`.
|
||||
::: note
|
||||
Every Boom's functions is delegated to the context. It means that `ctx.notFound` is a shortcut to `ctx.response.notFound`.
|
||||
:::
|
||||
|
||||
### API Reference
|
||||
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
See the [filters' concepts](../concepts/concepts.md#filters) for details.
|
||||
|
||||
> Note: 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](#programmatic-usage) section.
|
||||
::: note
|
||||
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](#programmatic-usage) section.
|
||||
:::
|
||||
|
||||
## Available operators
|
||||
|
||||
@ -74,7 +76,9 @@ Requests system can be implemented in custom code sections.
|
||||
|
||||
To extract the filters from an JavaScript object or a request, you need to call the [`strapi.utils.models.convertParams` helper](../api-reference/reference.md#strapiutils).
|
||||
|
||||
> Note: The returned objects is formatted according to the ORM used by the model.
|
||||
::: note
|
||||
The returned objects is formatted according to the ORM used by the model.
|
||||
:::
|
||||
|
||||
#### Example
|
||||
|
||||
|
@ -41,7 +41,9 @@ module.exports = {
|
||||
};
|
||||
```
|
||||
|
||||
> Note: please make sure you installed `nodemailer` (`npm install nodemailer`) for this example.
|
||||
::: note
|
||||
please make sure you installed `nodemailer` (`npm install nodemailer`) for this example.
|
||||
:::
|
||||
|
||||
The service is now available through the `strapi.services` global variable. We can use it in another part of our codebase. For example a controller like below:
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
# File Upload
|
||||
|
||||
> ⚠️ This feature requires the Upload plugin (installed by default).
|
||||
::: warning
|
||||
This feature requires the Upload plugin (installed by default).
|
||||
:::
|
||||
|
||||
Thanks to the plugin `Upload`, you can upload any kind of files on your server or externals providers such as AWS S3.
|
||||
|
||||
@ -8,7 +10,9 @@ Thanks to the plugin `Upload`, you can upload any kind of files on your server o
|
||||
|
||||
The plugin exposes a single route `POST /upload` to upload one or multiple files in a single request.
|
||||
|
||||
> ⚠️ Please send the request using multipart/form-data encoding
|
||||
::: warning
|
||||
Please send the request using multipart/form-data encoding
|
||||
:::
|
||||
|
||||
**Parameters**
|
||||
|
||||
|
@ -69,7 +69,9 @@ You also will have to reset your roles permissions.
|
||||
|
||||
### Update bookshelf filters
|
||||
|
||||
> This update is if you come from version before alpha-11.3
|
||||
::: warning
|
||||
This update is if you come from version before alpha-11.3
|
||||
:::
|
||||
|
||||
You will have to replace your `fetchAll` services queries of your generated API:
|
||||
|
||||
|
@ -36,7 +36,9 @@ The structure of the configurations has been harmonised and simplified. Files ha
|
||||
Please refer to the [new documentation](../configurations/configurations.md) to set the correct values in each file.
|
||||
|
||||
|
||||
> Note: Don't forget that middlewares has been removed. Please refers to the right section of this document for more details.
|
||||
::: note
|
||||
Don't forget that middlewares has been removed. Please refers to the right section of this document for more details.
|
||||
:::
|
||||
|
||||
## Routes
|
||||
|
||||
@ -141,9 +143,13 @@ The services files should stay as they are. Your generator functions can be conv
|
||||
|
||||
The models didn't change a lot. The `autoCreatedAt`, `autoUpdatedAt` and `autoPK` attributes have been removed and replaced by the `hasTimestamps` attribute.
|
||||
|
||||
> Note: The `hasTimestamps` options will only work with Bookshelf. Also you need to create the `created_at` and `updated_at` columns manually.
|
||||
::: note
|
||||
The `hasTimestamps` options will only work with Bookshelf. Also you need to create the `created_at` and `updated_at` columns manually.
|
||||
:::
|
||||
|
||||
> Note: The `enum` type is not available for now. Also, the validations are not working properly. It means that most of the validations have to be done manually.
|
||||
::: note
|
||||
The `enum` type is not available for now. Also, the validations are not working properly. It means that most of the validations have to be done manually.
|
||||
:::
|
||||
|
||||
#### v1.x
|
||||
|
||||
@ -310,7 +316,9 @@ module.exports = {
|
||||
}
|
||||
```
|
||||
|
||||
> Note: You will have more changes if your project is based on a SQL database. Waterline and Mongoose are almost sharing the same API.
|
||||
::: note
|
||||
You will have more changes if your project is based on a SQL database. Waterline and Mongoose are almost sharing the same API.
|
||||
:::
|
||||
|
||||
## Middlewares
|
||||
|
||||
@ -351,7 +359,9 @@ It works exactly as before. You need to add `strapi-views` into your app's depen
|
||||
}
|
||||
```
|
||||
|
||||
> Note: You might have to install the template engine by your own (ex: `npm install ejs --save`).
|
||||
::: note
|
||||
You might have to install the template engine by your own (ex: `npm install ejs --save`).
|
||||
:::
|
||||
|
||||
## Error handling
|
||||
|
||||
|
@ -6,7 +6,9 @@ This section explains how the 'back-end part' of your plugin works.
|
||||
|
||||
The plugin API routes are defined in the `./plugins/**/config/routes.json` file.
|
||||
|
||||
> Please refer to [router documentation](../guides/routing.md) for informations.
|
||||
::: note
|
||||
Please refer to [router documentation](../guides/routing.md) for informations.
|
||||
:::
|
||||
|
||||
**Route prefix**
|
||||
|
||||
|
@ -73,7 +73,9 @@ To style a plugin component:
|
||||
|
||||
Use this style in the component: `<div className={styles.wrapper}></div>`.
|
||||
|
||||
Note: if you want to use several classes:
|
||||
::: note
|
||||
if you want to use several classes:
|
||||
:::
|
||||
|
||||
```js
|
||||
import cn from 'classnames';
|
||||
|
@ -10,9 +10,11 @@ To setup the development environment please **follow the instructions below:**
|
||||
2. Clone it to your computer `git clone git@github.com:strapi/strapi.git`.
|
||||
3. Run `npm run setup` at the root of the directory.
|
||||
|
||||
> You can run `npm run setup:build` to build the plugins' admin (the setup time will be longer)
|
||||
You can run `npm run setup:build` to build the plugins' admin (the setup time will be longer)
|
||||
|
||||
> Note: If the installation failed, please remove the global packages related to Strapi. The command `npm ls strapi` will help you to find where your packages are installed globally.
|
||||
::: note
|
||||
If the installation failed, please remove the global packages related to Strapi. The command `npm ls strapi` will help you to find where your packages are installed globally.
|
||||
:::
|
||||
|
||||
## Plugin development Setup
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user