Skip to content

Commit

Permalink
Merge pull request #19 from lemoncloud-io/feature/louis-remove-console
Browse files Browse the repository at this point in the history
chore: remove log statement
  • Loading branch information
louis-lemon authored Jun 6, 2024
2 parents cfacf48 + 2fc022b commit 1554b2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
11 changes: 4 additions & 7 deletions src/core/aws-web.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class AWSWebCore implements WebCoreService {
*/
constructor(private readonly config: WebCoreConfig<'aws'>) {
this.logger = new LoggerService('AWSCore');
this.logger.log('init AWSCore');
this.tokenStorage = new AWSStorageService(this.config);
}

Expand All @@ -31,34 +30,32 @@ export class AWSWebCore implements WebCoreService {
* @throws {Error} - Throws an error if there is no cached token.
*/
async init(): Promise<AWSWebCoreState> {
this.logger.log('initilze AWSWebCore');
const hasCachedToken = await this.tokenStorage.hasCachedToken();
if (!hasCachedToken) {
this.logger.warn('has no token!');
this.logger.warn('initialized without token!');
return 'no-token';
}

const shouldRefreshToken = await this.tokenStorage.shouldRefreshToken();
if (shouldRefreshToken) {
this.logger.info('should refresh token!');
const refreshed = await this.refreshCachedToken();
if (refreshed) {
await this.getCurrentCredentials();
this.logger.info('refreshed token');
this.logger.info('initialized and refreshed token!');
return 'refreshed';
}
}

const cachedToken = await this.tokenStorage.hasCachedToken();
if (!cachedToken) {
this.logger.warn('has no token!');
this.logger.warn('initialized without token!');
return 'no-token';
}

// build AWS credential without refresh
const credential = await this.tokenStorage.getCachedCredentials();
this.createAWSCredentials(credential);
this.logger.info('build credentials');
this.logger.info('initialized with token!');
return 'build';
}

Expand Down
7 changes: 3 additions & 4 deletions src/core/azure-web.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class AzureWebCore implements WebCoreService {
*/
constructor(private readonly config: WebCoreConfig<'azure'>) {
this.logger = new LoggerService('AzureCore');
this.logger.log('init AzureCore');
this.tokenStorage = new AzureStorageService(this.config);
}

Expand All @@ -27,18 +26,18 @@ export class AzureWebCore implements WebCoreService {
* @returns {Promise<AzureWebCoreState>} - The state of the Azure web core after initialization.
*/
async init(): Promise<AzureWebCoreState> {
this.logger.log('initialize AzureCore');
const hasCachedToken = await this.tokenStorage.hasCachedToken();
if (!hasCachedToken) {
this.logger.warn('has no token!');
this.logger.warn('initialized without token!');
return 'no-token';
}

const shouldRefreshToken = await this.tokenStorage.shouldRefreshToken();
if (shouldRefreshToken) {
this.logger.info('should refresh token!');
this.logger.info('initialized and refreshed token!');
// TODO: refresh azure token
}
this.logger.info('initialized with token!');
return 'has-token';
}

Expand Down

0 comments on commit 1554b2c

Please sign in to comment.