🔪🐛 Fixed pnpm in Dockerfile, moved config to src
All checks were successful
Deploy application / deploy (push) Successful in 10s
All checks were successful
Deploy application / deploy (push) Successful in 10s
This commit is contained in:
@ -4,7 +4,7 @@ import {
|
||||
ACTUAL_PASSWORD,
|
||||
ACTUAL_SERVER_URL,
|
||||
ACTUAL_SYNC_ID,
|
||||
} from "../config.ts"
|
||||
} from "@/config.ts"
|
||||
import type { TransactionEntity } from "@actual-app/api/@types/loot-core/types/models"
|
||||
import { type UUID } from "node:crypto"
|
||||
import logger from "@common/logger.ts"
|
||||
|
@ -2,7 +2,7 @@ import {
|
||||
BANK_INITIAL_REFRESH_TOKEN,
|
||||
BANK_OAUTH_CLIENT_ID,
|
||||
BANK_OAUTH_CLIENT_SECRET,
|
||||
} from "@/../config.ts"
|
||||
} from "@/config.ts"
|
||||
import logger from "@common/logger.ts"
|
||||
import dayjs, { type Dayjs } from "dayjs"
|
||||
import type { Database } from "better-sqlite3"
|
||||
|
55
src/config.ts
Normal file
55
src/config.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import assert from "node:assert"
|
||||
import dotenv from "dotenv"
|
||||
|
||||
dotenv.config()
|
||||
|
||||
// Actual
|
||||
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 = getOrDefault("ACTUAL_DATA_DIR", ".cache")
|
||||
|
||||
// Bank
|
||||
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")
|
||||
|
||||
// Configuration
|
||||
export const DB_DIRECTORY = getOrDefault("DB_DIRECTORY", "data")
|
||||
export const DB_FILENAME = getOrDefault("DB_FILENAME", "default")
|
||||
export const LOG_LEVEL = getOrDefault("LOG_LEVEL", "info")
|
||||
// TODO default to fetch 1 day
|
||||
// Relative number of days in the past to start fetching transactions from
|
||||
export const TRANSACTION_RELATIVE_FROM_DATE = getNumberOrDefault(
|
||||
"TRANSACTION_RELATIVE_FROM_DATE",
|
||||
4,
|
||||
)
|
||||
// Relative number of days in the past to end fetching transactions from
|
||||
export const TRANSACTION_RELATIVE_TO_DATE = getNumberOrDefault(
|
||||
"TRANSACTION_RELATIVE_TO_DATE",
|
||||
3,
|
||||
)
|
||||
|
||||
// Utility functions
|
||||
function getOrDefault(key: string, def: string): string {
|
||||
return process.env[key] || def
|
||||
}
|
||||
|
||||
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(",")
|
||||
}
|
||||
|
||||
function getNumberOrDefault(key: string, def: number): number {
|
||||
const num = Number(process.env[key])
|
||||
return Number.isNaN(num) ? def : num
|
||||
}
|
@ -8,7 +8,7 @@ import {
|
||||
DB_FILENAME,
|
||||
TRANSACTION_RELATIVE_FROM_DATE,
|
||||
TRANSACTION_RELATIVE_TO_DATE,
|
||||
} from "../config.ts"
|
||||
} from "@/config.ts"
|
||||
import logger from "@common/logger.ts"
|
||||
import type { UUID } from "node:crypto"
|
||||
import { createDb } from "@/bank/db/queries.ts"
|
||||
|
@ -1,7 +1,7 @@
|
||||
import type { UUID } from "node:crypto"
|
||||
import dayjs from "dayjs"
|
||||
import { type ActualTransaction } from "@/actual.ts"
|
||||
import { ACTUAL_ACCOUNT_IDS, BANK_ACCOUNT_IDS } from "../config.ts"
|
||||
import { ACTUAL_ACCOUNT_IDS, BANK_ACCOUNT_IDS } from "@/config.ts"
|
||||
import logger from "@common/logger.ts"
|
||||
import { toISODateString } from "@common/date.ts"
|
||||
import type { SB1Transaction } from "@sb1/types.ts"
|
||||
|
Reference in New Issue
Block a user