mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
📃 feat: add list-balances, remove-user, and improve User scripts (#1418)
* Refactoring opening of DB to config/helpers.js * Adding two user scripts: - 'delete-user' to remove a user definitely - 'list-balances' to show the balances of all the users
This commit is contained in:
parent
8735db0980
commit
1a95bef677
10 changed files with 137 additions and 82 deletions
|
|
@ -1,36 +1,11 @@
|
|||
const path = require('path');
|
||||
require('module-alias')({ base: path.resolve(__dirname, '..', 'api') });
|
||||
const { askQuestion, silentExit } = require('./helpers');
|
||||
const { askQuestion, silentExit, connectWithTimeout } = require('./helpers');
|
||||
const Transaction = require('~/models/Transaction');
|
||||
const connectDb = require('~/lib/db/connectDb');
|
||||
const User = require('~/models/User');
|
||||
|
||||
(async () => {
|
||||
/**
|
||||
* Connect to the database
|
||||
* - If it takes a while, we'll warn the user
|
||||
*/
|
||||
// Warn the user if this is taking a while
|
||||
let timeout = setTimeout(() => {
|
||||
console.orange(
|
||||
'This is taking a while... You may need to check your connection if this fails.',
|
||||
);
|
||||
timeout = setTimeout(() => {
|
||||
console.orange('Still going... Might as well assume the connection failed...');
|
||||
timeout = setTimeout(() => {
|
||||
console.orange('Error incoming in 3... 2... 1...');
|
||||
}, 13000);
|
||||
}, 10000);
|
||||
}, 5000);
|
||||
// Attempt to connect to the database
|
||||
try {
|
||||
console.orange('Warming up the engines...');
|
||||
await connectDb();
|
||||
clearTimeout(timeout);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
silentExit(1);
|
||||
}
|
||||
await connectWithTimeout();
|
||||
|
||||
/**
|
||||
* Show the welcome / help menu
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue