Skip to content

Commit

Permalink
fix: use @Injectable over @Bind
Browse files Browse the repository at this point in the history
Signed-off-by: Raymond Feng <enjoyjava@gmail.com>
  • Loading branch information
raymondfeng committed Oct 21, 2020
1 parent a4386e9 commit e28c1a5
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/site/Controller.md
Expand Up @@ -210,7 +210,7 @@ For example, the default naming convention for a path's `operationId` is
one `${controllerName}-${methodName}`, you can define an enhancer as:

```ts
import {bind} from '@loopback/core';
import {injectable} from '@loopback/core';
import {
mergeOpenAPISpec,
asSpecEnhancer,
Expand Down
4 changes: 2 additions & 2 deletions docs/site/Extending-Model-API-builder.md
Expand Up @@ -43,7 +43,7 @@ Then bind the builder with
so it can be used as an API builder option.

```ts
import {bind} from '@loopback/core';
import {injectable} from '@loopback/core';
import {asModelApiBulder, ModelApiBuilder} from '@loopback/model-api-builder';

@injectable(asModelApiBuilder)
Expand All @@ -54,7 +54,7 @@ Since the builder implements `ModelApiBuilder`, the `build` function must be
defined:

```ts
import {bind} from '@loopback/core';
import {injectable} from '@loopback/core';
import {
asModelApiBuilder,
ModelApiBuilder,
Expand Down
2 changes: 1 addition & 1 deletion docs/site/Extending-OpenAPI-specification.md
Expand Up @@ -30,7 +30,7 @@ For example, to modify the `info` field of an OAS, you can create an
`InfoSpecEnhancer` that implements interface `OASEnhancer` as follows:

```ts
import {bind} from '@loopback/core';
import {injectable} from '@loopback/core';
import {
mergeOpenAPISpec,
asSpecEnhancer,
Expand Down
Expand Up @@ -5,14 +5,14 @@

import {asAuthStrategy, AuthenticationStrategy} from '@loopback/authentication';
import {StrategyAdapter} from '@loopback/authentication-passport';
import {bind, extensionFor, inject} from '@loopback/core';
import {extensionFor, inject, injectable} from '@loopback/core';
import {RedirectRoute, Request} from '@loopback/rest';
import {UserProfile} from '@loopback/security';
import {Strategy} from 'passport-twitter';
import {User} from '../models';
import {mapProfile, PassportAuthenticationBindings} from './types';

@bind(
@injectable(
asAuthStrategy,
extensionFor(PassportAuthenticationBindings.OAUTH2_STRATEGY),
)
Expand Down
Expand Up @@ -4,11 +4,11 @@
// License text available at https://opensource.org/licenses/MIT

const passport = require('passport');
import {bind, BindingScope, inject, Provider} from '@loopback/core';
import {BindingScope, inject, injectable, Provider} from '@loopback/core';
import {ExpressRequestHandler} from '@loopback/rest';
import {Strategy as TwitterStrategy} from 'passport-twitter';

@bind.provider({scope: BindingScope.SINGLETON})
@injectable.provider({scope: BindingScope.SINGLETON})
export class TwitterOauthExpressMiddleware
implements Provider<ExpressRequestHandler> {
constructor(
Expand Down
Expand Up @@ -4,14 +4,14 @@
// License text available at https://opensource.org/licenses/MIT

import {UserIdentityService} from '@loopback/authentication';
import {bind, BindingScope, inject, Provider} from '@loopback/core';
import {BindingScope, inject, injectable, Provider} from '@loopback/core';
import {Profile} from 'passport';
import {IStrategyOption, Strategy as TwitterStrategy} from 'passport-twitter';
import {verifyFunctionFactory} from '../authentication-strategies/types';
import {User} from '../models';
import {UserServiceBindings} from '../services';

@bind.provider({scope: BindingScope.SINGLETON})
@injectable.provider({scope: BindingScope.SINGLETON})
export class TwitterOauth implements Provider<TwitterStrategy> {
strategy: TwitterStrategy;

Expand Down
Expand Up @@ -3,7 +3,7 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {bind, config, Provider} from '@loopback/core';
import {config, injectable, Provider} from '@loopback/core';
import {Client, expect} from '@loopback/testlab';
import {Router} from 'express';
import {ExpressServer, Middleware} from '../../';
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('Express middleware registry', () => {
it('registers a LoopBack middleware provider with config injection', async () => {
type TestSpyConfig = {headerName: string};

@bind(asMiddleware({group: 'spy'}))
@injectable(asMiddleware({group: 'spy'}))
class SpyMiddlewareProviderWithConfig implements Provider<Middleware> {
@config()
private options: TestSpyConfig;
Expand Down

0 comments on commit e28c1a5

Please sign in to comment.