mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-22 00:13:45 -05:00
Extract sync related server handlers from main.ts to server/sync/app.ts (#4661)
* Extract sync related server handlers from main.ts to server/sync/app.ts * Release notes * Revert async
This commit is contained in:
committed by
GitHub
parent
6b2d2420a5
commit
1e685b993b
@@ -58,8 +58,8 @@ import {
|
||||
makeTestMessage,
|
||||
clearFullSyncTimeout,
|
||||
resetSync,
|
||||
repairSync,
|
||||
} from './sync';
|
||||
import { app as syncApp } from './sync/app';
|
||||
import * as syncMigrations from './sync/migrate';
|
||||
import { app as toolsApp } from './tools/app';
|
||||
import { app as transactionsApp } from './transactions/app';
|
||||
@@ -114,14 +114,6 @@ handlers['query'] = async function (query) {
|
||||
return aqlQuery(query);
|
||||
};
|
||||
|
||||
handlers['sync-reset'] = async function () {
|
||||
return await resetSync();
|
||||
};
|
||||
|
||||
handlers['sync-repair'] = async function () {
|
||||
await repairSync();
|
||||
};
|
||||
|
||||
// A user can only enable/change their key with the file loaded. This
|
||||
// will change in the future: during onboarding the user should be
|
||||
// able to enable encryption. (Imagine if they are importing data from
|
||||
@@ -445,10 +437,6 @@ handlers['set-server-url'] = async function ({ url, validate = true }) {
|
||||
return {};
|
||||
};
|
||||
|
||||
handlers['sync'] = async function () {
|
||||
return fullSync();
|
||||
};
|
||||
|
||||
handlers['validate-budget-name'] = async function ({ name }) {
|
||||
return validateBudgetName(name);
|
||||
};
|
||||
@@ -1106,6 +1094,7 @@ app.combine(
|
||||
accountsApp,
|
||||
payeesApp,
|
||||
spreadsheetApp,
|
||||
syncApp,
|
||||
);
|
||||
|
||||
export function getDefaultDocumentDir() {
|
||||
|
||||
29
packages/loot-core/src/server/sync/app.ts
Normal file
29
packages/loot-core/src/server/sync/app.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createApp } from '../app';
|
||||
|
||||
import { repairSync as _repairSync } from './repair';
|
||||
import { resetSync as _resetSync } from './reset';
|
||||
|
||||
import { fullSync } from '.';
|
||||
|
||||
export type SyncHandlers = {
|
||||
sync: typeof sync;
|
||||
'sync-reset': typeof resetSync;
|
||||
'sync-repair': typeof repairSync;
|
||||
};
|
||||
|
||||
export const app = createApp<SyncHandlers>();
|
||||
app.method('sync', sync);
|
||||
app.method('sync-reset', resetSync);
|
||||
app.method('sync-repair', repairSync);
|
||||
|
||||
async function sync() {
|
||||
return await fullSync();
|
||||
}
|
||||
|
||||
async function resetSync() {
|
||||
return await _resetSync();
|
||||
}
|
||||
|
||||
async function repairSync() {
|
||||
await _repairSync();
|
||||
}
|
||||
4
packages/loot-core/src/types/handlers.d.ts
vendored
4
packages/loot-core/src/types/handlers.d.ts
vendored
@@ -10,6 +10,7 @@ import type { ReportsHandlers } from '../server/reports/app';
|
||||
import type { RulesHandlers } from '../server/rules/app';
|
||||
import type { SchedulesHandlers } from '../server/schedules/app';
|
||||
import type { SpreadsheetHandlers } from '../server/spreadsheet/app';
|
||||
import type { SyncHandlers } from '../server/sync/app';
|
||||
import type { ToolsHandlers } from '../server/tools/app';
|
||||
import type { TransactionHandlers } from '../server/transactions/app';
|
||||
|
||||
@@ -32,6 +33,7 @@ export interface Handlers
|
||||
ToolsHandlers,
|
||||
AccountHandlers,
|
||||
PayeesHandlers,
|
||||
SpreadsheetHandlers {}
|
||||
SpreadsheetHandlers,
|
||||
SyncHandlers {}
|
||||
|
||||
export type HandlerFunctions = Handlers[keyof Handlers];
|
||||
|
||||
@@ -22,10 +22,6 @@ export interface ServerHandlers {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
query: (query: Query) => Promise<{ data: any; dependencies: string[] }>;
|
||||
|
||||
'sync-reset': () => Promise<{ error?: { reason: string; meta?: unknown } }>;
|
||||
|
||||
'sync-repair': () => Promise<unknown>;
|
||||
|
||||
'key-make': (arg: {
|
||||
password;
|
||||
}) => Promise<{ error?: { reason: string; meta?: unknown } }>;
|
||||
|
||||
Reference in New Issue
Block a user