Skip to content

Commit 41d7db8

Browse files
committed
chore: remove unnecessary top level async
1 parent dea8d84 commit 41d7db8

File tree

1 file changed

+30
-34
lines changed

1 file changed

+30
-34
lines changed

packages/nhsNotifyLambda/cli/test-token-exchange.ts

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,40 @@ import axiosRetry from "axios-retry"
1919
import {tokenExchange} from "../src/utils/auth.js"
2020
import {NotifySecrets} from "../src/utils/secrets.js"
2121

22-
async function main() {
23-
const logger = initLogger()
24-
const {host} = loadNotifyConfig(logger)
25-
const notifySecrets = loadNotifySecrets(logger)
26-
const axiosInstance = initAxiosInst(host)
27-
28-
logger.info("Testing token exchange", {
22+
const logger = initLogger()
23+
const {host} = loadNotifyConfig(logger)
24+
const notifySecrets = loadNotifySecrets(logger)
25+
const axiosInstance = initAxiosInst(host)
26+
27+
logger.info("Testing token exchange", {
28+
host,
29+
apiKeyPrefix: notifySecrets.apiKey.substring(0, 10) + "...",
30+
kid: notifySecrets.kid
31+
})
32+
33+
try {
34+
// Perform token exchange
35+
const accessToken = await tokenExchange(
36+
logger,
37+
axiosInstance,
2938
host,
30-
apiKeyPrefix: notifySecrets.apiKey.substring(0, 10) + "...",
31-
kid: notifySecrets.kid
39+
notifySecrets
40+
)
41+
42+
logger.info("Token exchange successful!", {
43+
tokenPrefix: accessToken.substring(0, 20) + "...",
44+
tokenLength: accessToken.length
3245
})
46+
console.log("\n✅ SUCCESS!")
3347

34-
try {
35-
// Perform token exchange
36-
const accessToken = await tokenExchange(
37-
logger,
38-
axiosInstance,
39-
host,
40-
notifySecrets
41-
)
42-
43-
logger.info("Token exchange successful!", {
44-
tokenPrefix: accessToken.substring(0, 20) + "...",
45-
tokenLength: accessToken.length
46-
})
47-
console.log("\n✅ SUCCESS!")
48-
49-
process.exit(0)
50-
51-
} catch (error) {
52-
logger.error("Token exchange failed", {error})
53-
console.error("\n❌ FAILED!")
54-
console.error(`\nError: ${error instanceof Error ? error.message : String(error)}\n`)
55-
process.exit(1)
56-
}
57-
}
48+
process.exit(0)
5849

59-
main()
50+
} catch (error) {
51+
logger.error("Token exchange failed", {error})
52+
console.error("\n❌ FAILED!")
53+
console.error(`\nError: ${error instanceof Error ? error.message : String(error)}\n`)
54+
process.exit(1)
55+
}
6056

6157
function initAxiosInst(host: string) {
6258
const axiosInstance = axios.create({

0 commit comments

Comments
 (0)