diff --git a/pages/en/lb4/Calling-other-APIs-and-Web-Services.md b/pages/en/lb4/Calling-other-APIs-and-Web-Services.md index 5970ab5c2..211c2c96d 100644 --- a/pages/en/lb4/Calling-other-APIs-and-Web-Services.md +++ b/pages/en/lb4/Calling-other-APIs-and-Web-Services.md @@ -25,9 +25,9 @@ $ npm install --save @loopback/service-proxy ### Define a data source for the service backend ```ts -import {DataSourceConstructor, juggler} from '@loopback/service-proxy'; +import {juggler} from '@loopback/service-proxy'; -const ds: juggler.DataSource = new DataSourceConstructor({ +const ds: juggler.DataSource = new juggler.DataSource({ name: 'GoogleMapGeoCode', connector: 'rest', options: { diff --git a/pages/en/lb4/Implementing-features.md b/pages/en/lb4/Implementing-features.md index 90bfefbe0..53845c838 100644 --- a/pages/en/lb4/Implementing-features.md +++ b/pages/en/lb4/Implementing-features.md @@ -309,9 +309,9 @@ Welcome to `@loopback/repository`, a TypeScript facade for the Create `src/datasources/db.datasource.ts` with the following content: ```ts - import {juggler, DataSourceConstructor} from '@loopback/repository'; + import {juggler} from '@loopback/repository'; - export const db = new DataSourceConstructor({ + export const db = new juggler.DataSource({ connector: 'memory', }); ``` diff --git a/pages/en/lb4/Repositories.md b/pages/en/lb4/Repositories.md index a46f03e18..74156c11a 100644 --- a/pages/en/lb4/Repositories.md +++ b/pages/en/lb4/Repositories.md @@ -9,7 +9,9 @@ summary: --- A Repository is a type of _Service_ that represents a collection of data within -a DataSource. +a DataSource. A repository class is a lightweight object, its instances can be +created with low runtime overhead. Typically a new repository instance is +created for each incoming request. ## Example Application @@ -56,10 +58,10 @@ follows: ```ts // src/datsources/db.datasource.ts -import {juggler, DataSourceConstructor} from '@loopback/repository'; +import {juggler} from '@loopback/repository'; // this is just an example, 'test' database doesn't actually exist -export const db = new DataSourceConstructor({ +export const db = new juggler.DataSource({ connector: 'mysql', host: 'localhost', port: 3306, diff --git a/pages/en/lb4/Reserved-binding-keys.md b/pages/en/lb4/Reserved-binding-keys.md index d9bb63d3a..37f430835 100644 --- a/pages/en/lb4/Reserved-binding-keys.md +++ b/pages/en/lb4/Reserved-binding-keys.md @@ -19,19 +19,19 @@ defined. You can change the default behavior by overriding the default binding, but you must ensure the interface of the new binding is the same as the default (but behavior can be different). -Following is a list that documents the binding keys in use by various -`@loopback` packages and their `Type` so you can easily look at their interface -in the [API Docs](http://apidocs.loopback.io). - It is recommended to use the CONSTANT defined for each binding key in it's respective namespace. You can import a namespace and access the binding key in your application as follows: ```js import {BindingKeyNameSpace} from 'package-name'; + app.bind(BindKeyNameSpace.KeyName).to('value'); ``` +Following is a list of links to the apidocs on the binding keys in use by +various `@loopback` packages: + {% include note.html title="Declaring new binding keys" content="For component developers creating a new Binding, to avoid conflict with other packages, it is recommended that the binding key start with the package name as the prefix. @@ -39,175 +39,9 @@ Example: `@loopback/authentication` component uses the prefix `authentication` for its binding keys. " %} -## Package: authentication - -**Reserved prefixes:** - -```text -authentication.* -``` - -### CONSTANT Namespace - -```js -import {AuthenticationBindings} from '@loopback/authentication'; -``` - -### Binding keys - -**Sequence Actions binding keys** - -| Name | CONSTANT | `Type` | Description | -| ------------------------------------- | ------------- | ---------------- | ------------------------------------------------------------------- | -| `authentication.actions.authenticate` | `AUTH_ACTION` | `AuthenticateFn` | Provides the authenticate function to be called in Sequence action. | - -**Other binding keys** - -| Name | CONSTANT | Type | Description | -| ---------------------------------- | -------------- | ------------------------ | ---------------------------------------------------------- | -| `authentication.currentUser` | `CURRENT_USER` | `UserProfile` | Authenticated user profile for the current request | -| `authentication.operationMetadata` | `METADATA` | `AuthenticationMetadata` | Authentication Metadata | -| `authentication.strategy` | `STRATEGY` | `Strategy` | Provider for a [passport](http://passportjs.org/) strategy | - -## Package: context - -**Reserved prefixes:** - -```text -context.* -``` - -### Binding keys - -_None_ - -## Package: core - -**Reserved prefixes:** - -```text -core.* -``` - -```text -controllers.* -``` - -### CONSTANT Namespace - -```js -import {CoreBindings} from '@loopback/authentication'; -``` - -### Binding keys - -| Name | CONSTANT | Type | Description | -| -------------------------------- | ------------------------ | -------------------- | --------------------------------------------------------------------------- | -| `application.apiSpec` | `API_SPEC` | `OpenApiSpec` | OpenAPI Specification describing your application's routes | -| `bindElement` | `BIND_ELEMENT` | `BindElement` | Convenience provider function to bind value to `Context` | -| `components.${component.name}` | | `Component` | Components used by your application | -| `controllers.${controller.name}` | | `ControllerClass` | The controller's bound to the application | -| `controller.current.ctor` | `CONTROLLER_CLASS` | `ControllerClass` | The controller for the current request | -| `controller.current.operation` | `CONTROLLER_METHOD_NAME` | `string` | Name of the operation for the current request | -| `controller.method.meta` | `CONTROLLER_METHOD_META` | `ControllerMetaData` | Metadata for a given controller | -| `getFromContext` | `GET_FROM_CONTEXT` | `GetFromContext` | Convenience provider function to return the `BoundValue` from the `Context` | - -## Package: rest - -| Name | CONSTANT | Type | Description | -| -------------------------------------------- | --------------- | ----------------- | ------------------------------------- | -| `rest.handler` | `HANDLER` | `HttpHandler` | The HTTP Request Handler | -| `rest.port` | `PORT` | `number` | HTTP Port the application will run on | -| `rest.http.request` | `Http.REQUEST` | `ServerRequest` | The raw `http` request | -| object | | | | -| `rest.http.request.context` | `Http.CONTEXT` | `Context` | Request level | -| context | | | | -| `rest.http.response` | `Http.RESPONSE` | `ServerResponse` | The raw `http` | -| response object | | | | -| `routes.${route.verb}.${route.path}` | | `RouteEntry` | Route entry | -| specified in api-spec | | | | -| `rest.sequence` | `SEQUENCE` | `SequenceHandler` | Class that | -| implements the sequence for your application | | | | - -**Rest Sequence Action Binding Keys** - -To use the Rest Sequence Actions CONSTANTs, bind/inject to -`RestBindings.SequenceActions.CONSTANT` _OR_ - -```js -const SequenceActions = RestBindings.SequenceActions; -SequenceActions.CONSTANT; // CONSTANT to bind/inject -``` - -| Name | CONSTANT | Type | Description | -| ------------------------------- | --------------- | -------------- | ------------------------------------------------------------------------------- | -| `sequence.actions.findRoute` | `FIND_ROUTE` | `FindRoute` | Sequence action to find the route for a given request | -| `sequence.actions.invokeMethod` | `INVOKE_METHOD` | `InvokeMethod` | Sequence action to invoke the operation method defined for the requested route | -| `sequence.actions.logError` | `LOG_ERROR` | `LogError` | Sequence action to log information about a failed request | -| `sequence.actions.parseParams` | `PARSE_PARAMS` | `ParseParams` | Sequence action to parse a request for arguments to be passed to the controller | -| `sequence.actions.reject` | `REJECT` | `Reject` | Sequence action to reject the request with an error | -| `sequence.actions.send` | `SEND` | `Send` | Sequence action to send the response back to client | - -## Package: openapi-spec - -**Reserved prefixes:** - -```text -api-spec.* -``` - -### Binding keys - -_None_ - -## Package: openapi-spec-builder - -**Reserved prefixes:** - -```text -spec-builder.* -``` - -### Binding keys - -_None_ - -## Package: repository - -**Reserved prefixes:** - -```text -repository.* -``` - -```text -repositories.*` -``` - -```text -datasources.* -``` - -```text -models.* -``` - -### Binding keys - -| Name | CONSTANT | Type | Description | -| -------------------------------- | -------- | ------------ | ------------------------------ | -| `datasources.${dataSourceName}` | | `DataSource` | Instance of a given datasource | -| `models.${modelName}` | | `Model` | Instance of a given model | -| `repositories.${repositoryName}` | | `Repository` | Instance of a given repository | - -## Package: testlab - -**Reserved prefixes:** - -```text -testlab.* -``` - -### Binding keys - -_None_ +- [AuthenticationBindings](http://apidocs.loopback.io/@loopback%2fdocs/authentication.html#AuthenticationBindings) +- [BootBindings](http://apidocs.loopback.io/@loopback%2fdocs/boot.html#BootBindings) +- [CoreBindings](http://apidocs.loopback.io/@loopback%2fdocs/core.html#CoreBindings) +- [RestBindings](http://apidocs.loopback.io/@loopback%2fdocs/rest.html#RestBindings) +- [RestBindings.Http](http://apidocs.loopback.io/@loopback%2fdocs/rest.html#Http) +- [RestBindings.SequenceActions](http://apidocs.loopback.io/@loopback%2fdocs/rest.html#SequenceActions) diff --git a/pages/en/lb4/todo-tutorial-datasource.md b/pages/en/lb4/todo-tutorial-datasource.md index 9a839af21..e4a00514b 100644 --- a/pages/en/lb4/todo-tutorial-datasource.md +++ b/pages/en/lb4/todo-tutorial-datasource.md @@ -37,18 +37,18 @@ this tutorial, we'll be using the memory connector provided with the Juggler. ``` Inside the `src/datasources` directory create a new file called `db.datasource.ts`. This file will create -a strongly-typed export of our datasource using the `DataSourceConstructor`, +a strongly-typed export of our datasource using the `juggler.DataSource`, which we can consume in our application via injection. #### src/datasources/db.datasource.ts ```ts import * as path from 'path'; -import {DataSourceConstructor, juggler} from '@loopback/repository'; +import {juggler} from '@loopback/repository'; const dsConfigPath = path.resolve('config', 'datasources.json'); const config = require(dsConfigPath); -export const db = new DataSourceConstructor(config); +export const db = new juggler.DataSource(config); ``` Once you're ready, we'll move onto adding a [repository](todo-tutorial-repository.md) for the diff --git a/pages/en/lb4/todo-tutorial-juggler.md b/pages/en/lb4/todo-tutorial-juggler.md index 7efadbdc3..1490dbe3e 100644 --- a/pages/en/lb4/todo-tutorial-juggler.md +++ b/pages/en/lb4/todo-tutorial-juggler.md @@ -38,13 +38,12 @@ import {MySequence} from './sequence'; // Binding and Booter imports are required to infer types for BootMixin! import {BootMixin, Booter, Binding} from '@loopback/boot'; -// juggler and DataSourceConstructor imports are required to infer types for RepositoryMixin! +// juggler imports are required to infer types for RepositoryMixin! import { Class, Repository, RepositoryMixin, juggler, - DataSourceConstructor, } from '@loopback/repository'; /* tslint:enable:no-unused-variable */ diff --git a/pages/en/lb4/todo-tutorial-putting-it-together.md b/pages/en/lb4/todo-tutorial-putting-it-together.md index e1c228578..c69144367 100644 --- a/pages/en/lb4/todo-tutorial-putting-it-together.md +++ b/pages/en/lb4/todo-tutorial-putting-it-together.md @@ -45,13 +45,12 @@ import {db} from './datasources/db.datasource'; // Binding and Booter imports are required to infer types for BootMixin! import {BootMixin, Booter, Binding} from '@loopback/boot'; -// juggler and DataSourceConstructor imports are required to infer types for RepositoryMixin! +// juggler imports are required to infer types for RepositoryMixin! import { Class, Repository, RepositoryMixin, juggler, - DataSourceConstructor, } from '@loopback/repository'; /* tslint:enable:no-unused-variable */ @@ -83,7 +82,7 @@ export class TodoListApplication extends BootMixin( // use a "real" datasource! const datasource = this.options && this.options.datasource - ? new DataSourceConstructor(this.options.datasource) + ? new juggler.DataSource(this.options.datasource) : db; this.dataSource(datasource); }