Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a3959eb
[dev/latest-guides-auth-request] Fixed grammatical error (#431)
Brlaney Oct 1, 2021
b855ce2
npm build command doesn't work. Use npm run build (#440)
nwazuo Oct 13, 2021
c349b2f
Update note in v3 migration guides (#449)
derrickmehaffy Oct 20, 2021
6f9e3f7
fix publicationState filter docs (#425)
petr-hajek Oct 21, 2021
525a2b7
Merge branch 'main' into next-3
pwizla Oct 22, 2021
9f7842f
Merge branch 'next' into dev/next-3
pwizla Oct 22, 2021
d752ca2
[v4] Dev docs: Shorter backend customizations intro (#458)
pwizla Oct 29, 2021
d445653
[v4] Dev docs: cron jobs (#463)
pwizla Nov 2, 2021
d18217b
[v4] Dev docs: CLI updates (#467)
pwizla Nov 3, 2021
d2d0844
[v4] Dev docs updates to services (#453)
pwizla Nov 3, 2021
b0f8a5e
[v4] Dev docs: Add API token documentation (#457)
pwizla Nov 3, 2021
1a06307
[v4] Dev docs: Update command name for template generation (#474)
pwizla Nov 4, 2021
2411915
[v4] Dev docs updates to routes (#450)
pwizla Nov 4, 2021
e69cb45
Clarify with policyContext
pwizla Nov 4, 2021
b5ade82
[v4] Dev docs: Add destroy() + update functions (#462)
pwizla Nov 4, 2021
a70becb
[v4] Dev docs: Move admin configuration out of server configuration …
pwizla Nov 4, 2021
79e30a7
[v4] Dev docs updates to policies (#451)
pwizla Nov 5, 2021
30ecbcf
Update after policies refactoring (#477)
pwizla Nov 8, 2021
cb5a218
[v4] Dev docs: Add error handling (#460)
pwizla Nov 8, 2021
91eabef
[v4] Dev docs: Add more GraphQL customizations: auth, policies, middl…
pwizla Nov 8, 2021
8765a67
[v4] Dev docs: Update i18n with new REST & GraphQL syntax (#466)
pwizla Nov 8, 2021
5e05d64
[v4] Dev docs updates to controllers (#452)
pwizla Nov 8, 2021
5b54d0c
[v4] Dev docs updates to middlewares (#455)
pwizla Nov 8, 2021
d1aea1e
[v4] User Guide: API token documentation (#464)
meganelacheny Nov 8, 2021
4a40a8c
Update controllers code examples
pwizla Nov 8, 2021
1b8f249
Add callout about Error catching guide
pwizla Nov 8, 2021
a3c51a4
Disable API token and count with GraphQL guides
pwizla Nov 8, 2021
972f8c4
Fix broken links (1 on 2)
pwizla Nov 8, 2021
0299930
Merge branch 'next' into dev/next-3
pwizla Nov 8, 2021
490e4c5
Fix broken links (2 on 2)
pwizla Nov 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ const sidebar = {
children: [
['/developer-docs/latest/setup-deployment-guides/configurations/required/databases.md', 'Database'],
['/developer-docs/latest/setup-deployment-guides/configurations/required/server.md', 'Server'],
['/developer-docs/latest/setup-deployment-guides/configurations/required/admin-panel.md', 'Admin panel'],
['/developer-docs/latest/setup-deployment-guides/configurations/required/middlewares.md', 'Middlewares'],
]
},
{
title: 'Optional configurations',
collapsable: true,
children: [
['/developer-docs/latest/setup-deployment-guides/configurations/optional/middlewares.md', 'Middlewares'],
['/developer-docs/latest/setup-deployment-guides/configurations/optional/functions.md', 'Functions'],
['/developer-docs/latest/setup-deployment-guides/configurations/optional/cronjobs.md', 'Cron jobs'],
['/developer-docs/latest/setup-deployment-guides/configurations/optional/api.md', 'API'],
['/developer-docs/latest/setup-deployment-guides/configurations/optional/plugins.md', 'Plugins'],
['/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.md', 'Environment'],
Expand Down Expand Up @@ -149,11 +151,13 @@ const sidebar = {
initialOpenGroupIndex: -1, // make sure that no subgroup is expanded by default
children: [
{
title: 'Backend customization',
title: 'Back-end customization',
collapsable: true,
path: '/developer-docs/latest/development/backend-customization',
children: [
['/developer-docs/latest/development/backend-customization/routing.md', 'Routing'],
['/developer-docs/latest/development/backend-customization/routes.md', 'Routes'],
['/developer-docs/latest/development/backend-customization/policies.md', 'Policies'],
['/developer-docs/latest/development/backend-customization/middlewares.md', 'Middlewares'],
['/developer-docs/latest/development/backend-customization/controllers.md', 'Controllers'],
['/developer-docs/latest/development/backend-customization/requests-responses.md', 'Requests & Responses'],
['/developer-docs/latest/development/backend-customization/services.md', 'Services'],
Expand Down Expand Up @@ -334,15 +338,15 @@ const sidebar = {
]
},
['/developer-docs/latest/developer-resources/cli/CLI', 'Command Line Interface'],
['/developer-docs/latest/developer-resources/error-handling.md', 'Error handling'],
],
},
{
title: '📚 Guides',
collapsable: true,
children: [
['/developer-docs/latest/guides/api-token', 'API tokens'],
['/developer-docs/latest/guides/auth-request', 'Authenticated request'],
['/developer-docs/latest/guides/count-graphql', 'Count with GraphQL'],
// ['/developer-docs/latest/guides/count-graphql', 'Count with GraphQL'],
['/developer-docs/latest/guides/slug', 'Create a slug system'],
['/developer-docs/latest/guides/is-owner', 'Create is owner policy'],
['/developer-docs/latest/guides/custom-admin', 'Custom admin'],
Expand Down
187 changes: 45 additions & 142 deletions docs/developer-docs/latest/developer-resources/cli/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ options: [--no-optimization]
- **strapi build --no-optimization**<br/>
Builds the administration panel without minimizing the assets. The build duration is faster.

## strapi watch-admin

Starts the admin server. Strapi should already be running with `strapi develop`.

```sh
strapi watch-admin
options: [--browser <name>]
```

## strapi configuration:dump

**Alias**: `config:dump`
Expand Down Expand Up @@ -183,181 +192,75 @@ strapi admin:reset-user-password --email=chef@strapi.io --password=Gourmet1234
| -p, --password | string | New password for the user |
| -h, --help | | display help for command |

## strapi generate:api
## strapi generate

Scaffold a complete API with its configurations, controller, model and service.
Run a fully interactive CLI to generate APIs, [controllers](/developer-docs/latest/development/backend-customization/controllers.md), [content-types](/developer-docs/latest/development/backend-customization/models.md), [plugins](/developer-docs/latest/development/plugins-development.md#creating-a-plugin), [policies](/developer-docs/latest/development/backend-customization/policies.md), [middlewares](/developer-docs/latest/development/backend-customization/middlewares.md) and [services](/developer-docs/latest/development/backend-customization/services.md).

```bash
strapi generate:api <name> [<attribute:type>]

options: [--plugin <name>]
```sh
strapi generate
```

- **strapi generate:api &#60;name&#62;**<br/>
Generates an API called **&#60;name&#62;** in the `./api` folder at the root of your project.

- **strapi generate:api &#60;name&#62; --draft-and-publish=true**<br/>
Generates an API called **&#60;name&#62;** in the `./api` folder at the root of your project and enabled the draft/publish feature.

- **strapi generate:api &#60;name&#62; &#60;attribute:type&#62;**<br/>
Generates an API called **&#60;name&#62;** in the `./api` folder at the root of your project. The model will already contain an attribute called **&#60;attribute&#62;** with the type property set to **&#60;type&#62;**.
## strapi templates:generate

Example: `strapi generate:api product name:string description:text price:integer`

- **strapi generate:api &#60;name&#62; --plugin &#60;plugin&#62;**<br/>
Generates an API called **&#60;name&#62;** in the `./plugins/<plugin>` folder.

Example: `strapi generate:api product --plugin content-manager`

::: tip TIPS
* The filename will be kebab-cased.
* When you create a new API using the CLI, a model is automatically created.
:::

## strapi generate:controller

Create a new controller.
Create a template from the current strapi project

```bash
strapi generate:controller <name>

options: [--api <name>|--plugin <name>]
strapi templates:generate <path>
```

- **strapi generate:controller &#60;name&#62;**<br/>
Generates an empty controller called **&#60;name&#62;** in the `./api/<name>/controllers` folder.

Example: `strapi generate:controller category` will create the controller at `./api/category/controllers/Category.js`.

- **strapi generate:controller &#60;name&#62; --api &#60;api&#62;**<br/>
Generates an empty controller called **&#60;name&#62;** in the `./api/<api>/controllers` folder.

Example: `strapi generate:controller category --api product` will create the controller at `./api/product/controllers/Category.js`.

- **strapi generate:controller &#60;name&#62; --plugin &#60;plugin&#62;**<br/>
Generates an empty controller called **&#60;name&#62;** in the `./plugins/<plugin>/controllers` folder.
- **strapi templates:generate &#60;path&#62;**<br/>
Generates a Strapi template at `<path>`

::: tip
The first letter of the filename will be uppercase.
:::
Example: `strapi templates:generate ../strapi-template-name` will copy the required files and folders to a `template` directory inside `../strapi-template-name`

## strapi generate:model
## strapi routes:list

Create a new model.
Display a list of all the available [routes](/developer-docs/latest/development/backend-customization/routes.md).

```bash
strapi generate:model <name> [<attribute:type>]

options: [--api <name>|--plugin <name>|--draft-and-publish <boolean>]
```sh
strapi routes:list
```

- **strapi generate:model &#60;name&#62;**<br/>
Generates an empty model called **&#60;name&#62;** in the `./api/<name>/models` folder. It will create two files.
The first one will be **&#60;name&#62;.js** which contains your lifecycle callbacks and another **&#60;name&#62;.settings.json** that will list your attributes and options.

Example: `strapi generate:model category` will create these two files `./api/category/models/Category.js` and `./api/category/models/Category.settings.json`.

- **strapi generate:model &#60;name&#62; &#60;attribute:type&#62;**<br/>
Generates an empty model called **&#60;name&#62;** in the `./api/<name>/models` folder. The file **&#60;name&#62;.settings.json** will already contain a list of attribute with their associated **&#60;type&#62;**.

Example: `strapi generate:model category name:string description:text` will create these two files `./api/category/models/Category.js` and `./api/category/models/Category.settings.json`. This last file will contain two attributes `name` with the type `string` and `description` with type `text`.

- **strapi generate:model &#60;name&#62; --api &#60;api&#62;**<br/>
Generates an empty model called **&#60;name&#62;** in the `./api/<api>/models` folder.

Example: `strapi generate:model category --api product` will create these two files:

- `./api/product/models/Category.js`
- `./api/product/models/Category.settings.json`.
## strapi policies:list

* **strapi generate:model &#60;name&#62; --plugin &#60;plugin&#62;**<br/>
Generates an empty model called **&#60;name&#62;** in the `./plugins/<plugin>/models` folder.
Display a list of all the registered [policies](/developer-docs/latest/development/backend-customization/policies.md).

* **strapi generate:model &#60;name&#62; --draft-and-publish=true**<br/>
Generates an empty model called **&#60;name&#62;** in the `./plugins/<plugin>/models` folder with the draft/publish feature enabled

::: tip
The first letter of the filename will be uppercase.
:::

## strapi generate:service

Create a new service.

```bash
strapi generate:service <name>

options: [--api <name>|--plugin <name>]
```sh
strapi policies:list
```

- **strapi generate:service &#60;name&#62;**<br/>
Generates an empty service called **&#60;name&#62;** in the `./api/<name>/services` folder.

Example: `strapi generate:service category` will create the service at `./api/category/services/Category.js`.
## strapi middlewares:list

- **strapi generate:service &#60;name&#62; --api &#60;api&#62;**<br/>
Generates an empty service called **&#60;name&#62;** in the `./api/<api>/services` folder.
Display a list of all the registered [middlewares](/developer-docs/latest/development/backend-customization/middlewares.md).

Example: `strapi generate:service category --api product` will create the service at `./api/product/services/Category.js`.

- **strapi generate:service &#60;name&#62; --plugin &#60;plugin&#62;**<br/>
Generates an empty service called **&#60;name&#62;** in the `./plugins/<plugin>/services` folder.

::: tip
The first letter of the filename will be uppercase.
:::

## strapi generate:policy

Create a new policy.

```bash
strapi generate:policy <name>

options: [--api <name>|--plugin <name>]
```sh
strapi middlewares:list
```

- **strapi generate:policy &#60;name&#62;**<br/>
Generates an empty policy called **&#60;name&#62;** in the `./config/policies` folder.

Example: `strapi generate:policy isAuthenticated` will create the policy at `./config/policies/isAuthenticated.js`.

- **strapi generate:policy &#60;name&#62; --api &#60;api&#62;**<br/>
Generates an empty policy called **&#60;name&#62;** in the `./api/<api>/config/policies` folder. This policy will be scoped and only accessible by the **&#60;api&#62;** routes.

Example: `strapi generate:policy isAuthenticated --api product` will create the policy at `./api/product/config/policies/isAuthenticated.js`.
## strapi content-types:list

- **strapi generate:policy &#60;name&#62; --plugin &#60;plugin&#62;**<br/>
Generates an empty policy called **&#60;name&#62;** in the `./plugins/<plugin>/config/policies` folder. This policy will be scoped and accessible only by the **&#60;plugin&#62;** routes.
Display a list of all the existing [content-types](/developer-docs/latest/development/backend-customization/models.md).

## strapi generate:plugin

Create a new plugin skeleton.

```bash
strapi generate:plugin <name>
```sh
strapi content-types:list
```

- **strapi generate:plugin &#60;name&#62;**<br/>
Generates an empty plugin called **&#60;name&#62;** in the `./plugins` folder.
<!-- ? should we document this? only returns strapi::content-types.beforeSync and afterSync on a new project, and I don't want people to get confused as we officially "remove" hooks ? -->
## strapi hooks:list

Example: `strapi generate:plugin user` will create the plugin at `./plugins/user`.
Display a list of all the available hooks.

Please refer to the [plugins development](/developer-docs/latest/development/plugins-development.md) section to know more.

## strapi generate:template

Create a template from the current strapi project

```bash
strapi generate:template <path>
```sh
strapi hooks:list
```

- **strapi generate:template &#60;path&#62;**<br/>
Generates a Strapi template at `<path>`
## strapi services:list

Example: `strapi generate:template ../strapi-template-name` will copy the required files and folders to a `template` directory inside `../strapi-template-name`
Display a list of all the registered [services](/developer-docs/latest/development/backend-customization/services.md).

```sh
strapi services:list
```

## strapi install

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ description: …

# Entity Service API: Components and dynamic zones

The [Entity Service](/developer-docs/latest/developer-resources/database-apis-reference/entity-service-api.md) is the layer that handles [components](/developer-docs/latest/development/backend-customization/models.html#components-2) and [dynamic zones](/developer-docs/latest/development/backend-customization/models.html#dynamic-zones) logic. With the Entity Service API, components and dynamic zones can be [created](#creation) and [updated](#update) while creating or updating entries.
The [Entity Service](/developer-docs/latest/developer-resources/database-apis-reference/entity-service-api.md) is the layer that handles [components](/developer-docs/latest/development/backend-customization/models.md#components-2) and [dynamic zones](/developer-docs/latest/development/backend-customization/models.md#dynamic-zones) logic. With the Entity Service API, components and dynamic zones can be [created](#creation) and [updated](#update) while creating or updating entries.

## Creation

A [component](/developer-docs/latest/development/backend-customization/models.html#components-2) can be created while creating an entry with the Entity Service API:
A [component](/developer-docs/latest/development/backend-customization/models.md#components-2) can be created while creating an entry with the Entity Service API:

```js
strapi.entityService.create('api::article.article', {
Expand All @@ -23,7 +23,7 @@ strapi.entityService.create('api::article.article', {
});
```

A [dynamic zone](/developer-docs/latest/development/backend-customization/models.html#dynamic-zones) (i.e. a list of components) can be created while creating an entry with the Entity Service API:
A [dynamic zone](/developer-docs/latest/development/backend-customization/models.md#dynamic-zones) (i.e. a list of components) can be created while creating an entry with the Entity Service API:

```js
strapi.entityService.create('api::article.article', {
Expand All @@ -44,7 +44,7 @@ strapi.entityService.create('api::article.article', {

## Update

A [component](/developer-docs/latest/development/backend-customization/models.html#components-2) can be updated while updating an entry with the Entity Service API. If a component `id` is specified, the component is updated, otherwise the old one is deleted and a new one is created:
A [component](/developer-docs/latest/development/backend-customization/models.md#components-2) can be updated while updating an entry with the Entity Service API. If a component `id` is specified, the component is updated, otherwise the old one is deleted and a new one is created:

```js
strapi.entityService.update('api::article.article', 1, {
Expand All @@ -57,7 +57,7 @@ strapi.entityService.update('api::article.article', 1, {
});
```

A [dynamic zone](/developer-docs/latest/development/backend-customization/models.html#dynamic-zones) (i.e. a list of components) can be updated while updating an entry with the Entity Service API. If a component `id` is specified, the component is updated, otherwise the old one is deleted and a new one is created:
A [dynamic zone](/developer-docs/latest/development/backend-customization/models.md#dynamic-zones) (i.e. a list of components) can be updated while updating an entry with the Entity Service API. If a component `id` is specified, the component is updated, otherwise the old one is deleted and a new one is created:

```js
strapi.entityService.update('api::article.article', 1, {
Expand Down
Loading