MCPcopy Create free account
hub / github.com/subquery/subql / checkToken

Function checkToken

packages/cli/src/utils/utils.ts:57–75  ·  view source on GitHub ↗
(token_path: string = ACCESS_TOKEN_PATH)

Source from the content-addressed store, hash-verified

55}
56
57export async function checkToken(token_path: string = ACCESS_TOKEN_PATH): Promise<string> {
58 const reqInput = () => input({message: 'Token cannot be found, Enter token', required: true});
59
60 const envToken = process.env.SUBQL_ACCESS_TOKEN;
61 if (envToken) return envToken;
62 if (existsSync(token_path)) {
63 try {
64 const authToken = readFileSync(token_path, 'utf8');
65 if (!authToken) {
66 return await reqInput();
67 }
68 return authToken.trim();
69 } catch (e) {
70 return reqInput();
71 }
72 } else {
73 return reqInput();
74 }
75}
76
77export function getOptionalToken(token_path: string = ACCESS_TOKEN_PATH): string | undefined {
78 const envToken = process.env.SUBQL_ACCESS_TOKEN;

Callers 6

createDeploymentAdapterFunction · 0.90
createProjectAdapterFunction · 0.90
deleteProjectAdapterFunction · 0.90
deleteDeploymentAdapterFunction · 0.90
promoteAdapterFunction · 0.90

Calls 1

reqInputFunction · 0.85

Tested by

no test coverage detected