
- accessToken and refreshToken methods from interface - accessToken param from transactionsPastDay - Unused env variables from config.ts Added - Initial Refresh token to env - Dayjs library for working with dates Implemented - getAccessToken - getRefreshToken - fetchNewRefreshToken - transactionsPastDay Signed-off-by: Martin Berg Alstad <git@martials.no>
28 lines
935 B
TypeScript
28 lines
935 B
TypeScript
import assert from "node:assert"
|
|
import dotenv from "dotenv"
|
|
|
|
dotenv.config()
|
|
|
|
export const ACTUAL_SYNC_ID = getOrThrow("ACTUAL_SYNC_ID")
|
|
export const ACTUAL_SERVER_URL = getOrThrow("ACTUAL_SERVER_URL")
|
|
export const ACTUAL_PASSWORD = getOrThrow("ACTUAL_PASSWORD")
|
|
export const ACTUAL_ACCOUNT_IDS = getArrayOrThrow("ACTUAL_ACCOUNT_IDS")
|
|
export const ACTUAL_DATA_DIR = ".cache"
|
|
|
|
export const BANK_INITIAL_REFRESH_TOKEN = getOrThrow(
|
|
"BANK_INITIAL_REFRESH_TOKEN",
|
|
)
|
|
export const BANK_OAUTH_CLIENT_ID = getOrThrow("BANK_OAUTH_CLIENT_ID")
|
|
export const BANK_OAUTH_CLIENT_SECRET = getOrThrow("BANK_OAUTH_CLIENT_SECRET")
|
|
export const BANK_ACCOUNT_IDS = getArrayOrThrow("BANK_ACCOUNT_IDS")
|
|
|
|
function getOrThrow(key: string): string {
|
|
const value = process.env[key]
|
|
assert(value, `Missing environment variable: ${key}`)
|
|
return value
|
|
}
|
|
|
|
function getArrayOrThrow(key: string): ReadonlyArray<string> {
|
|
return getOrThrow(key).split(",")
|
|
}
|