Add more logging and a qualified api path
This commit is contained in:
parent
b975eef1f1
commit
1e750c6cdb
1 changed files with 5 additions and 1 deletions
|
|
@ -45,8 +45,9 @@ async function init() {
|
||||||
app.use(cors())
|
app.use(cors())
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
app.post('/transaction', async function (req, res, _next) {
|
app.post('/actual-api/transaction', async function (req, res, _next) {
|
||||||
await lock.acquire('transaction', async () => {
|
await lock.acquire('transaction', async () => {
|
||||||
|
console.debug('Executing Transaction');
|
||||||
try {
|
try {
|
||||||
await api.init({
|
await api.init({
|
||||||
dataDir: config.dataDir,
|
dataDir: config.dataDir,
|
||||||
|
|
@ -54,9 +55,12 @@ async function init() {
|
||||||
password: config.password,
|
password: config.password,
|
||||||
});
|
});
|
||||||
const transaction = makeTransaction(parse(req.body), config.accountId);
|
const transaction = makeTransaction(parse(req.body), config.accountId);
|
||||||
|
console.log(transaction);
|
||||||
await api.addTransactions(config.accountId, [transaction]);
|
await api.addTransactions(config.accountId, [transaction]);
|
||||||
|
console.log(`Successfully logged "${transaction.payee_name} - ¥${transaction.amount}"`);
|
||||||
return res.json({ result: 'success' });
|
return res.json({ result: 'success' });
|
||||||
} catch {
|
} catch {
|
||||||
|
console.log('Transaction failed...');
|
||||||
return res.json({ result: 'failure' });
|
return res.json({ result: 'failure' });
|
||||||
} finally {
|
} finally {
|
||||||
await api.shutdown();
|
await api.shutdown();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue