2024-01-11 11:37:54 -05:00
|
|
|
const { FileSources } = require('librechat-data-provider');
|
|
|
|
const { initializeFirebase } = require('./Files/Firebase/initialize');
|
|
|
|
const loadCustomConfig = require('./Config/loadCustomConfig');
|
|
|
|
const paths = require('~/config/paths');
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Loads custom config and initializes app-wide variables.
|
|
|
|
* @function AppService
|
|
|
|
* @param {Express.Application} app - The Express application object.
|
|
|
|
*/
|
|
|
|
const AppService = async (app) => {
|
2024-02-05 09:31:18 +01:00
|
|
|
/** @type {TCustomConfig}*/
|
2024-01-11 11:37:54 -05:00
|
|
|
const config = (await loadCustomConfig()) ?? {};
|
2024-02-05 09:31:18 +01:00
|
|
|
const socialLogins = config.registration.socialLogins ?? [
|
|
|
|
'google',
|
|
|
|
'facebook',
|
|
|
|
'openid',
|
|
|
|
'github',
|
|
|
|
'discord',
|
|
|
|
];
|
2024-01-11 11:37:54 -05:00
|
|
|
const fileStrategy = config.fileStrategy ?? FileSources.local;
|
|
|
|
process.env.CDN_PROVIDER = fileStrategy;
|
|
|
|
|
|
|
|
if (fileStrategy === FileSources.firebase) {
|
|
|
|
initializeFirebase();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.locals = {
|
2024-02-05 09:31:18 +01:00
|
|
|
socialLogins,
|
2024-01-11 11:37:54 -05:00
|
|
|
fileStrategy,
|
|
|
|
paths,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = AppService;
|