Skip to content

Commit

Permalink
refactor: repository
Browse files Browse the repository at this point in the history
  • Loading branch information
jannyHou committed Apr 9, 2020
1 parent 3be50db commit 63f544b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import {
} from '@loopback/testlab';
import {genSalt, hash} from 'bcryptjs';
import * as _ from 'lodash';
import {TestApplication} from '../fixtures/application';
import {UserServiceBindings} from '../..';
import {UserRepository} from '../../repositories';
import {TestApplication} from '../fixtures/application';

describe('jwt authentication', () => {
let app: TestApplication;
Expand Down Expand Up @@ -54,7 +55,7 @@ describe('jwt authentication', () => {
});

await app.boot();
userRepo = await app.get('repositories.UserRepository');
userRepo = await app.get(UserServiceBindings.USER_REPOSITORY_NAME);
await createUsers();
await app.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ export class JWTAuthenticationComponent implements Component {

// user bindings
Binding.bind(UserServiceBindings.USER_SERVICE).toClass(MyUserService),
Binding.bind('repositories.UserRepository').toClass(UserRepository),
Binding.bind('repositories.UserCredentialsRepository').toClass(
Binding.bind(UserServiceBindings.USER_REPOSITORY_NAME).toClass(
UserRepository,
),
Binding.bind(UserServiceBindings.USER_CREDENTIALS_REPOSITORY_NAME).toClass(
UserCredentialsRepository,
),
];
Expand Down
3 changes: 3 additions & 0 deletions extensions/authentication-jwt/src/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ export namespace UserServiceBindings {
'services.user.service',
);
export const DATASOURCE_NAME = 'jwtdb';
export const USER_REPOSITORY_NAME = 'repositories.UserRepository';
export const USER_CREDENTIALS_REPOSITORY_NAME =
'repositories.UserCredentialsRepository';
}

0 comments on commit 63f544b

Please sign in to comment.