Skip to content

Commit 2a707f0

Browse files
committed
fix: changing JwtAdapter types
1 parent 638d642 commit 2a707f0

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

.husky/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npm run test:coveralls
4+
npm run test-coveralls

.lintstagedrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"*.ts": [
33
"eslint 'src/**' --fix",
4-
"npm run test:staged"
4+
"npm run test-staged"
55
]
66
}

globalConfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"mongoUri":"mongodb://127.0.0.1:61353/","mongoDBName":"jest"}
1+
{"mongoUri":"mongodb://127.0.0.1:61828/","mongoDBName":"jest"}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export interface Decrypter {
2-
decrypt(token: string): Promise<string>;
2+
decrypt(token: string): string;
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export interface Encrypter {
2-
encrypt(value: string): Promise<string>;
2+
encrypt(value: string): string;
33
}

src/data/usecases/authentication/db-authentication.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class DbAuthentication implements Authentication {
2525
account.password
2626
);
2727
if (isValid) {
28-
const accessToken = await this.encrypter.encrypt(account.id);
28+
const accessToken = this.encrypter.encrypt(account.id);
2929
await this.updateAccessTokenRepository.updateAccessToken(
3030
account.id,
3131
accessToken

src/data/usecases/load-account-by-token/db-load-account-by-token.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class DbLoadAccountByToken implements LoadAccountByToken {
1212
) {}
1313

1414
async load(accessToken: string, role?: string): Promise<AccountModel> {
15-
const token = await this.decrypter.decrypt(accessToken);
15+
const token = this.decrypter.decrypt(accessToken);
1616
if (token) {
1717
const account = await this.loadAccountByTokenRepository.loadByToken(
1818
accessToken,

src/infra/criptography/jwt-adapter/jwt-adapter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { Encrypter } from "../../../data/protocols/criptography/encrypter";
55
export class JwtAdapter implements Encrypter, Decrypter {
66
constructor(private readonly secret: string) {}
77

8-
async encrypt(value: string): Promise<string> {
9-
const accessToken = await jwt.sign({ id: value }, this.secret);
8+
encrypt(value: string): string {
9+
const accessToken = jwt.sign({ id: value }, this.secret);
1010
return accessToken;
1111
}
1212

13-
async decrypt(token: string): Promise<string> {
14-
const value: any = await jwt.verify(token, this.secret);
13+
decrypt(token: string): string {
14+
const value: any = jwt.verify(token, this.secret);
1515
return value;
1616
}
1717
}

0 commit comments

Comments
 (0)