Skip to content

Commit

Permalink
docs(example-getting-started): remove controller refs from juggler.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kjdelisle committed Mar 2, 2018
1 parent 1f82b10 commit e14b257
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions packages/example-getting-started/docs/juggler.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,42 @@ on those sources of data.
It also provides many of the functions and interfaces we'll require for setting
up our new LoopBack application, which is why we're starting here.

The application template comes with a controller, and some default wireup in
`src/application.ts` that handles the basic configuration for your application.
For this tutorial, we won't need `ping.controller.ts` or its corresponding test,
but you can leave them in for now.

Now that you have your setup, it's time to modify it to add in
`@loopback/repository`. Install this dependency by running
`npm i --save @loopback/repository`.

Next, modify `src/application.ts` to change the base class of your app to use
the `RepositoryMixin`:
The `application.ts` file that came with the application template should already
make use of the `RepositoryMixin`, which provides the functions required to use
the Legacy Juggler in your application.

#### src/application.ts
```ts
import {ApplicationConfig} from '@loopback/core';
import {RestApplication} from '@loopback/rest';
import {PingController} from './controllers/ping-controller';
import {Class, Repository, RepositoryMixin} from '@loopback/repository';

export class TodoApplication extends RepositoryMixin(RestApplication) {
/* tslint:disable:no-unused-variable */
// Do not remove!
// Class and Repository imports required to infer types in consuming code!
// Binding and Booter imports are required to infer types for BootMixin!
import {BootMixin, Booter, Binding} from '@loopback/boot';
import {
Class,
Repository,
RepositoryMixin,
} from '@loopback/repository';
/* tslint:enable:no-unused-variable */

export class TodoApplication extends BootMixin(
RepositoryMixin(RestApplication),
) {
constructor(options?: ApplicationConfig) {
super(options);
this.setupControllers();
}

setupControllers() {
this.controller(PingController);
this.projectRoot = __dirname;
// Customize @loopback/boot Booter Conventions here
this.bootOptions = {
controllers: {
// Customize ControllerBooter Conventions here
dirs: ['controllers'],
extensions: ['.controller.js'],
nested: true,
},
};
}
}
```
Expand Down

0 comments on commit e14b257

Please sign in to comment.