diff --git a/.gitignore b/.gitignore index 33f1a523..54410324 100644 --- a/.gitignore +++ b/.gitignore @@ -36,5 +36,5 @@ yarn-error.log* .env.test.local .env.production.local -*.development.yml +*.dev.yml diff --git a/lib/redis.js b/lib/redis.js index b059ddf6..24d81438 100644 --- a/lib/redis.js +++ b/lib/redis.js @@ -9,6 +9,10 @@ const INITIALIZED = 'redis:initialized'; export const DELETED = 'deleted'; function getClient() { + if (!process.env.REDIS_URL) { + return null; + } + const redis = new Redis(process.env.REDIS_URL); if (process.env.NODE_ENV !== 'production') { diff --git a/queries/admin/account/deleteAccount.js b/queries/admin/account/deleteAccount.js index 994cccd5..4e204e73 100644 --- a/queries/admin/account/deleteAccount.js +++ b/queries/admin/account/deleteAccount.js @@ -4,12 +4,16 @@ import redis, { DELETED } from 'lib/redis'; export async function deleteAccount(user_id) { const { client } = prisma; - const websiteUuids = await client.website - .findMany({ - where: { user_id }, - select: { website_uuid: true }, - }) - .map(a => a.website_uuid); + const websites = await client.website.findMany({ + where: { user_id }, + select: { website_uuid: true }, + }); + + let websiteUuids = []; + + if (websites.length > 0) { + websiteUuids = websites.map(a => a.website_uuid); + } return client .$transaction([