Skip to content

Commit

Permalink
docs(example-getting-started): apply more feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Delisle committed Feb 27, 2018
1 parent dbc6413 commit 9ed2e13
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Lastly, you'll need to install the LoopBack 4 CLI toolkit:
npm i -g @loopback/cli
```

If you'd like to continue the tutorial, then jump to the
[next section here](2-scaffold-app.md).
If you'd like to continue the tutorial, then move to the
[Create your app scaffolding](2-scaffold-app.md) section.

If you'd like to see the final results of this tutorial as an example
application, follow these steps:
Expand Down
7 changes: 5 additions & 2 deletions packages/example-getting-started/docs/6-repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ create two files:
Our TodoRepository will contain a small base class that uses the
`DefaultCrudRepository` class from
[`@loopback/repository`](https://github.com/strongloop/loopback-next/tree/master/packages/repository)
and will define the model type we're working with, as well as its ID type. We'll
also inject our datasource so that this repository can connect to it when
and will define the model type we're working with, as well as its ID type.
This automatically gives us the basic CRUD methods required for performing
operations against our database (or any other kind of datasource).

We'll also inject our datasource so that this repository can connect to it when
executing data operations.

#### src/repositories/todo.repository.ts
Expand Down
10 changes: 9 additions & 1 deletion packages/example-getting-started/docs/7-controller.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
### Create your controller

Now, we'll create a controller to handle our Todo routes. Create the
In LoopBack 4, controllers handle the request-response lifecycle for your API.
Each function on a controller can be addressed individually to handle
an incoming request (like a POST request to `/todo`), perform business logic
and then return a response.

In this respect, controllers are the regions _in which most of your business
logic will live_!

So, let's create a controller to handle our Todo routes. Create the
`src/controllers` directory and two files inside:
- `index.ts` (export helper)
- `todo.controller.ts`
Expand Down
17 changes: 14 additions & 3 deletions packages/example-getting-started/docs/8-putting-it-together.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ We've got all of our artifacts now, and all that's left is to bind them to our
[Dependency injection](http://loopback.io/doc/en/lb4/Dependency-injection.html)
system can tie it all together for us!

We'll define a new helper function for setting up the repositories, and
LoopBack's [boot module](https://github.com/strongloop/loopback-next/tree/master/packages/boot) will
take care of the other artifacts for us!
LoopBack's
[boot module](https://github.com/strongloop/loopback-next/tree/master/packages/boot)
will automatically discover our controllers, repositories, datasources and
other artifacts and inject them into our application for use.
In the current example, we've manually loaded our repository so that it can be
mocked/stubbed for unit testing purposes.

>**NOTE**: The boot module will only discover and inject artifacts that
follow our established conventions for artifact directories. Here are some
examples:
>* Controllers: `./src/controllers`
>* Datasources: `./src/datasources`
>* Models: `./src/models`
>* Repositories: `./src/repositories`
#### src/application.ts
```ts
Expand Down

0 comments on commit 9ed2e13

Please sign in to comment.