Fix Meilisearch error and refactor of the server index.js (#832)

* fix meilisearch error at startup

* limit the nesting

* disable useless console log

* fix(indexSync.js): removed redundant searchEnabled

* refactor(index.js): moved configureSocialLogins to a new file

* refactor(socialLogins.js): removed unnecessary conditional
This commit is contained in:
Marco Beretta 2023-08-24 21:59:11 +02:00 committed by GitHub
parent 37347d4683
commit a569020312
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 50 deletions

View file

@ -2,10 +2,14 @@ const Conversation = require('../../models/schema/convoSchema');
const Message = require('../../models/schema/messageSchema');
const { MeiliSearch } = require('meilisearch');
let currentTimeout = null;
const searchEnabled = process.env?.SEARCH?.toLowerCase() === 'true';
// eslint-disable-next-line no-unused-vars
async function indexSync(req, res, next) {
const searchEnabled = process.env.SEARCH && process.env.SEARCH.toLowerCase() === 'true';
if (!searchEnabled) {
return;
}
try {
if (!process.env.MEILI_HOST || !process.env.MEILI_MASTER_KEY || !searchEnabled) {
throw new Error('Meilisearch not configured, search will be disabled.');