Files
actual/packages/api/index.js
Jed Fox 93a1f8a944 Updates to the @actual-budget/api package (#464)
* 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
2023-02-23 23:01:05 -05:00

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,
};