feat: zentrale selfhost-dienste bereitstellen

This commit is contained in:
2026-08-02 16:34:10 +02:00
parent d3ad53bcf0
commit 8b8e0c97d3
30 changed files with 1818 additions and 74 deletions

View File

@@ -1,5 +1,6 @@
// /services/bankStatementService.ts
import axios from "axios"
import { centralServicesClient } from "../push-server.client"
import dayjs from "dayjs"
import utc from "dayjs/plugin/utc.js"
import {secrets} from "../../utils/secrets"
@@ -57,11 +58,13 @@ const normalizeDate = (val: any) => {
export function bankStatementService(server: FastifyInstance) {
let accessToken: string | null = null
const useCentralBanking = Boolean(secrets.FEDEO_CENTRAL_SERVICES_ENABLED && centralServicesClient.configured())
// -----------------------------------------------
// ✔ TOKEN LADEN
// -----------------------------------------------
const getToken = async () => {
if (useCentralBanking) return
console.log("Fetching GoCardless token…")
const response = await axios.post(
@@ -80,6 +83,7 @@ export function bankStatementService(server: FastifyInstance) {
// -----------------------------------------------
const getBalanceData = async (accountId: string): Promise<any | false> => {
try {
if (useCentralBanking) return await centralServicesClient.getBankingBalances(accountId)
const {data} = await axios.get(
`${secrets.GOCARDLESS_BASE_URL}/accounts/${accountId}/balances`,
{
@@ -114,6 +118,10 @@ export function bankStatementService(server: FastifyInstance) {
// -----------------------------------------------
const getTransactionData = async (accountId: string) => {
try {
if (useCentralBanking) {
const data = await centralServicesClient.getBankingTransactions(accountId)
return data.transactions.booked
}
const {data} = await axios.get<TransactionsResponse>(
`${secrets.GOCARDLESS_BASE_URL}/accounts/${accountId}/transactions`,
{