blob: 0875273629dd5fc86302c2c78e95d31ed6ef98fc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import { ACTUAL_BUDGET_ID, ACTUAL_HOST, ACTUAL_PASS } from "$env/static/private";
import * as actual from "@actual-app/api"
import { existsSync, mkdirSync } from "node:fs";
import path from "node:path"
import process from "node:process";
async function init_actual() {
const dataDir = path.resolve(process.cwd(), "data/actualDataDir")
if (!existsSync(dataDir)) mkdirSync(dataDir, { recursive: true });
return actual.init({
password: ACTUAL_PASS,
serverURL: ACTUAL_HOST,
dataDir: dataDir
}).then(async () => {
await actual.downloadBudget(ACTUAL_BUDGET_ID)
await actual.sync()
})
}
export async function get_budgets() {
await init_actual()
return actual.getBudgets()
}
export async function get_accounts() {
await init_actual()
return actual.getAccounts()
}
|