From 691731906d170a4126642a44fc62729a860ff52e Mon Sep 17 00:00:00 2001 From: nejat-njonjo Date: Fri, 28 Oct 2022 16:51:03 +0200 Subject: [PATCH] Added error check, reminding to run setup first --- lib/api/user.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/api/user.ts b/lib/api/user.ts index b8249f4..b862d88 100644 --- a/lib/api/user.ts +++ b/lib/api/user.ts @@ -67,6 +67,11 @@ export async function getFirstUser(): Promise { projection: { _id: 0, emailVerified: 0 } } ); + + if (!results) { + throw new Error('Please run "npm run setup" to insert testing records'); + } + return { ...results, bioMdx: await getMdxSource(results.bio || placeholderBio) @@ -123,7 +128,7 @@ export async function searchUser(query: string): Promise { { $search: { index: 'name-index', - /* + /* name-index is a search index as follows: {