From b883a2d96c0a1b0d22c300826c17b96a7b0880ef Mon Sep 17 00:00:00 2001 From: ivar Date: Wed, 10 Dec 2025 22:59:15 +0100 Subject: Add .gitattributes --- .gitattributes | 1 + app/package.json | 2 +- app/src/routes/+page.svelte | 8 ++++++-- app/src/routes/actual.remote.ts | 10 ++++++++-- app/src/routes/sb1.remote.ts | 7 ++----- 5 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fae8897 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* eol=lf diff --git a/app/package.json b/app/package.json index bfc6d8b..0644578 100644 --- a/app/package.json +++ b/app/package.json @@ -36,4 +36,4 @@ "dependencies": { "better-sqlite3": "^12.5.0" } -} +} \ No newline at end of file diff --git a/app/src/routes/+page.svelte b/app/src/routes/+page.svelte index ed35a84..005eb34 100644 --- a/app/src/routes/+page.svelte +++ b/app/src/routes/+page.svelte @@ -27,6 +27,10 @@ await refreshSB1Token(); getTokenExpires().refresh(); } + + async function initActual() { + await initActual() + }
@@ -37,7 +41,7 @@
accessToken: {tokens.accessToken.created.add({ seconds: tokens.accessToken.expires }).toLocaleString()}
 refreshToken: {tokens.refreshToken.created.add({ seconds: tokens.refreshToken.expires }).toLocaleString()}
- {:else} + {/if} {:else} diff --git a/app/src/routes/actual.remote.ts b/app/src/routes/actual.remote.ts index bcf5d37..535e387 100644 --- a/app/src/routes/actual.remote.ts +++ b/app/src/routes/actual.remote.ts @@ -1,10 +1,10 @@ -import { command } from "$app/server"; +import { command, query } from "$app/server"; import { 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"; -export const initActual = command(async () => { +async function initActual() { const dataDir = path.resolve(__dirname, "actualDataDir"); if (!existsSync(dataDir)) mkdirSync(dataDir); @@ -14,4 +14,10 @@ export const initActual = command(async () => { serverURL: ACTUAL_HOST, dataDir: dataDir }) +} + +export const getActualMeta = query(async () => { + await initActual() + const accounts = await actual.getAccounts() + return }) \ No newline at end of file diff --git a/app/src/routes/sb1.remote.ts b/app/src/routes/sb1.remote.ts index 3d5763e..17e1ead 100644 --- a/app/src/routes/sb1.remote.ts +++ b/app/src/routes/sb1.remote.ts @@ -31,7 +31,7 @@ async function createSb1Auth() { export const getAccounts = query(async () => { const token = await getSb1AccessToken() - if (!token) return [] + if (!token) return undefined const url = new URL( "https://api.sparebank1.no/personal/banking/accounts", ); @@ -41,9 +41,7 @@ export const getAccounts = query(async () => { }, }); if (response.ok) { - const json = await response.json() - console.log(json) - return json + return await response.json() as { accounts: Array } } else console.error(await response.text()) }) @@ -55,7 +53,6 @@ export const getTransactions = query(v.string(), async (accountKey: string) => { "https://api.sparebank1.no/personal/banking/transactions", ); url.searchParams.set("accountKey", accountKey); - console.log(token) const response = await fetch(url, { headers: { Authorization: `Bearer ${token}`, -- cgit v1.3