configure redis
This commit is contained in:
@@ -14,7 +14,7 @@ export async function createWebsite(user_id, data) {
|
||||
},
|
||||
})
|
||||
.then(async res => {
|
||||
if (process.env.REDIS_URL) {
|
||||
if (process.env.REDIS_URL && res) {
|
||||
await redis.set(`website:${res.website_uuid}`, Number(res.website_id));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ export async function deleteWebsite(website_id) {
|
||||
}),
|
||||
]).then(async res => {
|
||||
if (process.env.REDIS_URL) {
|
||||
await redis.del(`website:${res.website_uuid}`);
|
||||
await redis.client.del(`website:${res.website_uuid}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
import prisma from 'lib/prisma';
|
||||
import redis from 'lib/redis';
|
||||
|
||||
export async function getWebsiteByUuid(website_uuid) {
|
||||
return prisma.client.website.findUnique({
|
||||
where: {
|
||||
website_uuid,
|
||||
},
|
||||
});
|
||||
return prisma.client.website
|
||||
.findUnique({
|
||||
where: {
|
||||
website_uuid,
|
||||
},
|
||||
})
|
||||
.then(async res => {
|
||||
if (process.env.REDIS_URL && res) {
|
||||
await redis.client.set(`website:${res.website_uuid}`, 1);
|
||||
}
|
||||
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user