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

@ -53,12 +53,14 @@ const convoSchema = mongoose.Schema(
{ timestamps: true }
);
convoSchema.plugin(mongoMeili, {
host: process.env.MEILI_HOST,
apiKey: process.env.MEILI_KEY,
indexName: 'convos', // Will get created automatically if it doesn't exist already
primaryKey: 'conversationId'
});
if (process.env.MEILI_HOST && process.env.MEILI_KEY) {
convoSchema.plugin(mongoMeili, {
host: process.env.MEILI_HOST,
apiKey: process.env.MEILI_KEY,
indexName: 'convos', // Will get created automatically if it doesn't exist already
primaryKey: 'conversationId'
});
}
const Conversation = mongoose.models.Conversation || mongoose.model('Conversation', convoSchema);