Skip to content

Commit

Permalink
Changed objects to classes
Browse files Browse the repository at this point in the history
  • Loading branch information
vr-varad authored and rajdip-b committed Jul 29, 2024
1 parent 2e3a1af commit c3b64f8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
34 changes: 18 additions & 16 deletions apps/cli/src/http/auth.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import { Logger } from '@/util/logger'

const AuthController = {
async checkApiKeyValidity(baseUrl: string, apiKey: string): Promise<void> {
Logger.info('Checking API key validity...')
const response = await fetch(`${baseUrl}/api/api-key/access/live-updates`, {
headers: {
'x-keyshade-token': apiKey
class AuthControllerClass {
static async checkApiKeyValidity(baseUrl: string, apiKey: string): Promise<void> {
Logger.info('Checking API key validity...')
const response = await fetch(`${baseUrl}/api/api-key/access/live-updates`, {
headers: {
'x-keyshade-token': apiKey
}
})

if (!response.ok) {
throw new Error(
'API key is not valid. Please check the key and try again.'
)
}

Logger.info('API key is valid!')
}
})

if (!response.ok) {
throw new Error(
'API key is not valid. Please check the key and try again.'
)
}

Logger.info('API key is valid!')
}
}

const AuthController = new AuthControllerClass();

export default AuthController
6 changes: 4 additions & 2 deletions apps/cli/src/http/secret.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Configuration } from '@/types/command/run.types'

const SecretController = {
async fetchSecrets(
class SecretControllerClass {
static async fetchSecrets(
baseUrl: string,
apiKey: string,
projectId: string,
Expand All @@ -25,4 +25,6 @@ const SecretController = {
}
}

const SecretController = new SecretControllerClass();

export default SecretController
6 changes: 4 additions & 2 deletions apps/cli/src/http/variable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Configuration } from '@/types/command/run.types'

const VariableController = {
async fetchVariables(
class VariableControllerClass{
static async fetchVariables(
baseUrl: string,
apiKey: string,
projectId: string,
Expand All @@ -25,4 +25,6 @@ const VariableController = {
}
}

const VariableController = new VariableControllerClass();

export default VariableController

0 comments on commit c3b64f8

Please sign in to comment.