0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-20 22:12:38 -05:00

[ci] format

This commit is contained in:
Matthew Phillips 2024-03-18 12:06:35 +00:00 committed by astrobot-houston
parent 37a485b4d1
commit 34206ed60f

View file

@ -44,7 +44,10 @@ class ManagedRemoteAppToken implements ManagedAppToken {
}); });
} }
static async createToken(sessionToken: string, projectId: string): Promise<{ token: string; ttl: number; }> { static async createToken(
sessionToken: string,
projectId: string
): Promise<{ token: string; ttl: number }> {
const spinner = ora('Connecting to remote database...').start(); const spinner = ora('Connecting to remote database...').start();
const response = await safeFetch( const response = await safeFetch(
new URL(`${getAstroStudioUrl()}/auth/cli/token-create`), new URL(`${getAstroStudioUrl()}/auth/cli/token-create`),
@ -107,7 +110,7 @@ class ManagedRemoteAppToken implements ManagedAppToken {
clearTimeout(this.renewTimer); clearTimeout(this.renewTimer);
delete this.renewTimer; delete this.renewTimer;
if(this.tokenIsValid()) { if (this.tokenIsValid()) {
const response = await this.fetch('/auth/cli/token-renew', { const response = await this.fetch('/auth/cli/token-renew', {
token: this.token, token: this.token,
projectId: this.projectId, projectId: this.projectId,
@ -117,10 +120,13 @@ class ManagedRemoteAppToken implements ManagedAppToken {
this.renewTimer = this.createRenewTimer(); this.renewTimer = this.createRenewTimer();
} else { } else {
throw new Error(`Unexpected response: ${response.status} ${response.statusText}`); throw new Error(`Unexpected response: ${response.status} ${response.statusText}`);
} }
} else { } else {
try { try {
const { token, ttl } = await ManagedRemoteAppToken.createToken(this.session, this.projectId); const { token, ttl } = await ManagedRemoteAppToken.createToken(
this.session,
this.projectId
);
this.token = token; this.token = token;
this.ttl = ttl; this.ttl = ttl;
this.expires = getExpiresFromTtl(ttl); this.expires = getExpiresFromTtl(ttl);
@ -128,7 +134,9 @@ class ManagedRemoteAppToken implements ManagedAppToken {
} catch { } catch {
// If we get here we couldn't create a new token. Since the existing token // If we get here we couldn't create a new token. Since the existing token
// is expired we really can't do anything and should exit. // is expired we really can't do anything and should exit.
throw new Error(`Token has expired and attempts to renew it have failed, please try again.`); throw new Error(
`Token has expired and attempts to renew it have failed, please try again.`
);
} }
} }
} }