mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 20:44:32 -05:00
* Make it easier to build the bundle.api.js for the API
* Remove budgetId parameter, move config to top level of API
* that’s a breaking change
* Add support for signing into the server in init()
* Add api.downloadBudget(syncId, { password }) method
* Fix lint errors
* Refactor: extract out getSyncError
* api/download-budget: sync if possible instead of downloading
* Don’t bother with fetching remote files and installing key if the file is local
* *groupId
* FIx lint issues
* Remove extra close+reopen
* Refactor out duplicate load-budget logic
* Trailing commas
35 lines
601 B
JavaScript
35 lines
601 B
JavaScript
let bundle = require('./app/bundle.api.js');
|
|
let injected = require('./injected');
|
|
let methods = require('./methods');
|
|
let utils = require('./utils');
|
|
let actualApp;
|
|
|
|
async function init(config = {}) {
|
|
if (actualApp) {
|
|
return;
|
|
}
|
|
|
|
global.fetch = require('node-fetch');
|
|
|
|
await bundle.init(config);
|
|
actualApp = bundle.lib;
|
|
|
|
injected.send = bundle.lib.send;
|
|
return bundle.lib;
|
|
}
|
|
|
|
async function shutdown() {
|
|
if (actualApp) {
|
|
await actualApp.send('close-budget');
|
|
actualApp = null;
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
init,
|
|
shutdown,
|
|
utils,
|
|
internal: bundle.lib,
|
|
...methods,
|
|
};
|