chore: error handling for complete omission of env var

This commit is contained in:
Danny Avila 2023-03-22 09:38:38 -04:00
parent 277685c218
commit 5164cf46ac
4 changed files with 103 additions and 88 deletions

View file

@ -6,6 +6,10 @@ const { MeiliSearch } = require('meilisearch');
// eslint-disable-next-line no-unused-vars
async function indexSync(req, res, next) {
try {
if (!process.env.MEILI_HOST || !process.env.MEILI_KEY || !process.env.SEARCH) {
throw new Error('Meilisearch not configured, search will be disabled.');
}
const client = new MeiliSearch({
host: process.env.MEILI_HOST,
apiKey: process.env.MEILI_KEY