Skip to content

Commit 9b8c0df

Browse files
committed
Fix various quality issues
1 parent d6bc8ae commit 9b8c0df

File tree

17 files changed

+201
-207
lines changed

17 files changed

+201
-207
lines changed

.editorconfig

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
# Change these settings to your own preference
9+
indent_style = space
10+
indent_size = 4
11+
12+
# We recommend you to keep these unchanged
13+
end_of_line = lf
14+
charset = utf-8
15+
trim_trailing_whitespace = true
16+
insert_final_newline = true
17+
18+
[*.json]
19+
indent_style = space
20+
indent_size = 2
21+
22+
[*.md]
23+
trim_trailing_whitespace = false
24+
25+
[*.neon]
26+
indent_style = tab
27+
indent_size = 4
28+
29+
[*.xml]
30+
indent_style = space
31+
indent_size = 4
32+
33+
[*.{yaml,yml}]
34+
indent_style = space
35+
indent_size = 2
36+
trim_trailing_whitespace = false
37+
38+
[.circleci/config.yml]
39+
indent_style = space
40+
indent_size = 2
41+
42+
[.github/workflows/*.yml]
43+
indent_style = space
44+
indent_size = 2
45+
46+
[.gitmodules]
47+
indent_style = tab
48+
49+
[.proselintrc]
50+
indent_style = space
51+
indent_size = 2
52+
53+
[.travis.yml]
54+
indent_style = space
55+
indent_size = 2

client-generator/nextjs.md

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,15 @@ The Next.js Client Generator generates routes and components for Server Side Ren
1010

1111
Create a [Next.js application with express server](https://github.com/zeit/next.js/tree/canary/examples/custom-server-express). The easiest way is to execute:
1212

13-
```bash
14-
$ npx create-next-app --example custom-server-express your-app-name
15-
# or
16-
$ yarn create next-app --example custom-server-express your-app-name
17-
```
13+
$ npx create-next-app --example custom-server-express your-app-name
14+
# or
15+
$ yarn create next-app --example custom-server-express your-app-name
1816

1917
### Enabling Typescript
2018

2119
Install typescript dependencies
2220

23-
```bash
24-
$ yarn add @types/next @zeit/next-typescript
25-
```
21+
$ yarn add @types/next @zeit/next-typescript
2622

2723
Enable Typescript in your Next.js configuration file (`next.config.js`):
2824

@@ -72,33 +68,26 @@ Create a `tsconfig.json` file to store Typescript configuration:
7268

7369
Install required dependencies:
7470

75-
```bash
76-
$ yarn add lodash.get lodash.has @types/lodash isomorphic-unfetch
77-
```
71+
$ yarn add lodash.get lodash.has @types/lodash isomorphic-unfetch
7872

7973
## Starting the Project
8074

8175
You can launch the server with
82-
```bash
83-
$ yarn dev
84-
```
76+
77+
$ yarn dev
8578

8679
and access it through `http://localhost:3000`
8780

8881
## Generating Routes
8982

90-
```bash
91-
$ npx @api-platform/client-generator https://demo.api-platform.com src/ --generator next --resource book
92-
# Replace the URL by the entrypoint of your Hydra-enabled API
93-
```
83+
$ npx @api-platform/client-generator https://demo.api-platform.com src/ --generator next --resource book
84+
# Replace the URL by the entrypoint of your Hydra-enabled API
9485

9586
> Note: Omit the resource flag to generate files for all resource types exposed by the API.
9687
9788
If your express server is compatible with the `custom-server-express` Next.js example, you can use the `server-path` flag to specify path to the server file. Routes will be added automatically to this file, otherwise, you will receive some hints on how to them to your own custom server.
9889

99-
```bash
100-
$ npx @api-platform/client-generator https://demo.api-platform.com src/ --generator next --server-path ./server.js
101-
```
90+
$ npx @api-platform/client-generator https://demo.api-platform.com src/ --generator next --server-path ./server.js
10291

10392
Go to `https://localhost:3000/books/` to start using your app.
10493
That's it!

client-generator/react-native.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,20 @@ To run the command line tool, we also recommend using [npx](https://www.npmjs.co
99

1010
Create a React Native application using [Expo CLI](https://docs.expo.io/versions/latest/workflow/expo-cli).
1111

12-
```bash
13-
$ yarn global add expo-cli
14-
$ expo init my-app
15-
# When asked, choose to use the blank template
16-
$ cd my-app
17-
```
12+
$ yarn global add expo-cli
13+
$ expo init my-app
14+
# When asked, choose to use the blank template
15+
$ cd my-app
1816

1917
Install the required dependencies:
2018

21-
```bash
22-
$ yarn add redux react-redux redux-thunk redux-form react-native-elements react-native-router-flux react-native-vector-icons prop-types whatwg-url buffer react-native-event-source
23-
```
19+
$ yarn add redux react-redux redux-thunk redux-form react-native-elements react-native-router-flux react-native-vector-icons prop-types whatwg-url buffer react-native-event-source
2420

2521
## Generating a Native App
2622

2723
In the app directory, generate the files for the resource you want:
2824

29-
```bash
30-
$ npx @api-platform/client-generator https://demo.api-platform.com . --generator react-native --resource book
31-
```
25+
$ npx @api-platform/client-generator https://demo.api-platform.com . --generator react-native --resource book
3226

3327
Replace the URL with the entrypoint of your Hydra-enabled API.
3428
Omit the resource flag to generate files for all resource types exposed by the API.
@@ -100,9 +94,7 @@ export default class App extends Component {
10094

10195
The code is ready to be executed!
10296

103-
```bash
104-
$ expo start
105-
```
97+
$ expo start
10698

10799
## Screenshots in iOS Simulator
108100

client-generator/react.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,45 +24,33 @@ To use this generator you need [Node.js](https://nodejs.org/) and [Yarn](https:/
2424

2525
Bootstrap a React application:
2626

27-
```bash
28-
$ npx create-react-app client
29-
$ cd client
30-
```
27+
$ npx create-react-app client
28+
$ cd client
3129

3230
Install the required dependencies:
3331

34-
```bash
35-
$ yarn add redux react-redux redux-thunk redux-form react-router-dom connected-react-router prop-types lodash
36-
```
32+
$ yarn add redux react-redux redux-thunk redux-form react-router-dom connected-react-router prop-types lodash
3733

3834
Optionally, install Bootstrap and Font Awesome to get an app that looks good:
3935

40-
```bash
41-
$ yarn add bootstrap font-awesome
42-
```
36+
$ yarn add bootstrap font-awesome
4337

4438
Finally, start the integrated web server:
4539

46-
```bash
47-
$ yarn start
48-
```
40+
$ yarn start
4941

5042
## Generating a Progressive Web App
5143

5244
If you use the API Platform distribution, generating all the code you need for a given resource is as simple as running the following command:
5345

54-
```bash
55-
$ docker-compose exec client generate-api-platform-client --resource book
56-
```
46+
$ docker-compose exec client generate-api-platform-client --resource book
5747

5848
Omit the resource flag to generate files for all resource types exposed by the API.
5949

6050
If you don't use the standalone installation, run the following command instead:
6151

62-
```bash
63-
$ npx @api-platform/client-generator https://demo.api-platform.com src/ --resource book
64-
# Replace the URL by the entrypoint of your Hydra-enabled API
65-
```
52+
$ npx @api-platform/client-generator https://demo.api-platform.com src/ --resource book
53+
# Replace the URL by the entrypoint of your Hydra-enabled API
6654

6755
The code has been generated, and is ready to be executed!
6856
Register the reducers and the routes in the `client/src/index.js` file:

client-generator/typescript.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ The TypeScript Generator allows you to create [TypeScript interfaces](https://ww
44

55
To do so, run the client generator:
66

7-
```bash
8-
$ npx @api-platform/client-generator --generator typescript https://demo.api-platform.com src/ --resource foo
9-
# Replace the URL by the entrypoint of your Hydra-enabled API
10-
# "src/" represents where the interfaces will be generated
11-
# Omit the resource flag to generate files for all resource types exposed by the API
12-
```
7+
$ npx @api-platform/client-generator --generator typescript https://demo.api-platform.com src/ --resource foo
8+
# Replace the URL by the entrypoint of your Hydra-enabled API
9+
# "src/" represents where the interfaces will be generated
10+
# Omit the resource flag to generate files for all resource types exposed by the API
1311

1412
This command parses the Hydra documentation and creates one `.ts` file for each API Resource you have defined in your application, in the `interfaces` subfolder.
1513

@@ -19,9 +17,7 @@ NOTE: If you are not sure what the entrypoint is, see [Troubleshooting](troubles
1917

2018
Assuming you have 2 resources in your application, `Foo` and `Bar`, when you run
2119

22-
```bash
23-
npx @api-platform/client-generator --generator typescript https://demo.api-platform.com src/
24-
```
20+
$ npx @api-platform/client-generator --generator typescript https://demo.api-platform.com src/
2521

2622
you will obtain 2 `.ts` files arranged as following:
2723

core/file-upload.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ before proceeding. It will help you get a grasp on how the bundle works, and why
1212

1313
Install the bundle with the help of Composer:
1414

15-
```bash
16-
docker-compose exec php composer require vich/uploader-bundle
17-
```
15+
$ docker-compose exec php composer require vich/uploader-bundle
1816

1917
This will create a new configuration file that you will need to slightly change
2018
to make it look like this.

core/graphql.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# GraphQL Support
22

3-
## Overall View
4-
53
[GraphQL](http://graphql.org/) is a query language made to communicate with an API and therefore is an alternative to REST.
64

75
It has some advantages compared to REST: it solves the over-fetching or under-fetching of data, is strongly typed, and is capable of retrieving multiple and nested data in one go, but it also comes with drawbacks. For example it creates overhead depending on the request.
@@ -14,9 +12,7 @@ Once enabled, you have nothing to do: your schema describing your API is automat
1412

1513
To enable GraphQL and GraphiQL interface in your API, simply require the [graphql-php](https://webonyx.github.io/graphql-php/) package using Composer and clear the cache one more time:
1614

17-
```bash
18-
docker-compose exec php composer req webonyx/graphql-php && bin/console cache:clear
19-
```
15+
$ docker-compose exec php composer req webonyx/graphql-php && bin/console cache:clear
2016

2117
You can now use GraphQL at the endpoint: `https://localhost:8443/graphql`.
2218

core/mercure.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
API Platform can automatically send real time updates to the currently connected clients (webapps, mobile apps...) using [the Mercure protocol](https://mercure.rocks).
44

55
> *Mercure* is a protocol allowing to push data updates to web browsers and other HTTP clients in a convenient, fast, reliable and battery-efficient way. It is especially useful to publish real-time updates of resources served through web APIs, to reactive web and mobile apps.
6-
> - https://mercure.rocks
6+
>
7+
> https://mercure.rocks
78
89
API Platform detects changes made to your Doctrine entities, and sends the updated resources to the Mercure hub.
910
Then, the Mercure hub dispatches the updates to all connected clients using [Server-sent Events (SSE)](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events).
1011

1112
![Mercure subscriptions](images/mercure-subscriptions.png)
1213

13-
## Installing the Mercure Support
14+
## Installing Mercure Support
1415

15-
The Mercure support is already installed, configured and enabled in [the official distribution](../distribution/index.md).
16-
If you use the distribution, you have nothing more to do, and you can jump to the next section.
16+
Mercure support is already installed, configured and enabled in [the API Platform distribution](../distribution/index.md).
17+
If you use the distribution, you have nothing more to do, and you can skip to the next section.
1718

1819
If you have installed API Platform using another method (such as `composer require api`), you need to install a Mercure hub, and the [Symfony MercureBundle](https://github.com/symfony/mercure-bundle):
1920

core/mongodb.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,32 @@ the legacy [mongo](https://secure.php.net/manual/en/book.mongo.php) extension.
1616

1717
## Enabling MongoDB Support
1818

19-
If the mongodb PHP extension is not installed yet, [install it beforehand](https://secure.php.net/manual/en/mongodb.installation.pecl.php).
19+
If the `mongodb` PHP extension is not installed yet, [install it beforehand](https://secure.php.net/manual/en/mongodb.installation.pecl.php).
2020

21-
If you are using the [API Platform Distribution](../distribution/index.md), modify the Dockerfile to add the extension:
21+
If you are using the [API Platform Distribution](../distribution/index.md), modify the `Dockerfile` to add the extension:
2222

2323
```diff
24-
// api/Dockerfile
25-
26-
...
24+
# api/Dockerfile
2725
pecl install \
2826
apcu-${APCU_VERSION} \
2927
+ mongodb \
3028
; \
31-
...
29+
pecl clear-cache; \
3230
docker-php-ext-enable \
3331
apcu \
34-
opcache \
3532
+ mongodb \
33+
opcache \
3634
; \
37-
...
3835
```
3936

4037
Then rebuild the `php` image:
4138

42-
```bash
43-
docker-compose build php
44-
```
39+
$ docker-compose build php
4540

4641
Add a MongoDB image to the docker-compose file:
4742

4843
```yaml
4944
# docker-compose.yml
50-
5145
# ...
5246
db-mongodb:
5347
# In production, you may want to use a managed database service
@@ -69,17 +63,14 @@ Add a MongoDB image to the docker-compose file:
6963
Once the extension is installed, to enable the MongoDB support, require the [Doctrine MongoDB ODM bundle](https://github.com/doctrine/DoctrineMongoDBBundle)
7064
package using Composer:
7165

72-
```bash
73-
docker-compose exec php composer req doctrine/mongodb-odm-bundle:^4.0.0@beta doctrine/mongodb-odm:^2.0.0@beta
74-
```
66+
$ docker-compose exec php composer req doctrine/mongodb-odm-bundle:^4.0.0@beta doctrine/mongodb-odm:^2.0.0@beta
7567

7668
Execute the contrib recipe to have it already configured.
7769

7870
Change the MongoDB environment variables to match your Docker image:
7971

8072
```
8173
# api/.env
82-
8374
MONGODB_URL=mongodb://api-platform:!ChangeMe!@db-mongodb
8475
MONGODB_DB=api
8576
```
@@ -88,7 +79,6 @@ Change the configuration of API Platform to add the right mapping path:
8879

8980
```yaml
9081
# api/config/packages/api_platform.yaml
91-
9282
api_platform:
9383
# ...
9484

0 commit comments

Comments
 (0)