mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
* chore: update jest and mongodb-memory-server dependencies * fix: Anthropic edge case of increasing balance * refactor: Update token calculations in Transaction model/spec * refactor: `spendTokens` always record transactions, add Tx related tests * feat: Add error handling for CHECK_BALANCE environment variable * feat: Update import path for Balance model in Balance controller * chore: remove logging * refactor: Improve structured token spend logging in spendTokens.js * ci: add unit tests for spend token * ci: Improve structured token spend unit testing * chore: improve logging phrase for no tx spent from balance
9 lines
290 B
JavaScript
9 lines
290 B
JavaScript
const Balance = require('~/models/Balance');
|
|
|
|
async function balanceController(req, res) {
|
|
const { tokenCredits: balance = '' } =
|
|
(await Balance.findOne({ user: req.user.id }, 'tokenCredits').lean()) ?? {};
|
|
res.status(200).send('' + balance);
|
|
}
|
|
|
|
module.exports = balanceController;
|