From 9ed2e132c1d6e247290df77c11db3d8d1f7da1d4 Mon Sep 17 00:00:00 2001 From: Kevin Delisle Date: Tue, 27 Feb 2018 12:12:36 -0500 Subject: [PATCH] docs(example-getting-started): apply more feedback --- .../docs/1-prerequisites-and-setup.md | 4 ++-- .../docs/6-repository.md | 7 +++++-- .../docs/7-controller.md | 10 +++++++++- .../docs/8-putting-it-together.md | 17 ++++++++++++++--- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/packages/example-getting-started/docs/1-prerequisites-and-setup.md b/packages/example-getting-started/docs/1-prerequisites-and-setup.md index 9819818e968e..d5e572309811 100644 --- a/packages/example-getting-started/docs/1-prerequisites-and-setup.md +++ b/packages/example-getting-started/docs/1-prerequisites-and-setup.md @@ -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: diff --git a/packages/example-getting-started/docs/6-repository.md b/packages/example-getting-started/docs/6-repository.md index 896ab2cf70f0..66b3187967b4 100644 --- a/packages/example-getting-started/docs/6-repository.md +++ b/packages/example-getting-started/docs/6-repository.md @@ -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 diff --git a/packages/example-getting-started/docs/7-controller.md b/packages/example-getting-started/docs/7-controller.md index 3cccff7c8e11..3d27b553d3c4 100644 --- a/packages/example-getting-started/docs/7-controller.md +++ b/packages/example-getting-started/docs/7-controller.md @@ -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` diff --git a/packages/example-getting-started/docs/8-putting-it-together.md b/packages/example-getting-started/docs/8-putting-it-together.md index 4c7527f80e69..34a8b87e5881 100644 --- a/packages/example-getting-started/docs/8-putting-it-together.md +++ b/packages/example-getting-started/docs/8-putting-it-together.md @@ -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