2022-08-28 04:38:35 +00:00
|
|
|
import prisma from 'lib/prisma';
|
2022-08-27 03:21:53 +00:00
|
|
|
import redis from 'lib/redis';
|
2022-07-12 21:14:36 +00:00
|
|
|
|
2022-10-10 20:42:18 +00:00
|
|
|
export async function createWebsite(userId, data) {
|
2022-08-28 04:38:35 +00:00
|
|
|
return prisma.client.website
|
|
|
|
|
.create({
|
2022-07-12 21:14:36 +00:00
|
|
|
data: {
|
2022-11-01 06:42:37 +00:00
|
|
|
user: {
|
2022-07-12 21:14:36 +00:00
|
|
|
connect: {
|
2022-10-10 20:42:18 +00:00
|
|
|
id: userId,
|
2022-07-12 21:14:36 +00:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
...data,
|
|
|
|
|
},
|
2022-08-28 04:38:35 +00:00
|
|
|
})
|
|
|
|
|
.then(async res => {
|
2022-10-26 03:17:13 +00:00
|
|
|
if (redis.enabled && res) {
|
2022-11-01 06:42:37 +00:00
|
|
|
await redis.set(`website:${res.id}`, 1);
|
2022-08-28 04:38:35 +00:00
|
|
|
}
|
2022-08-27 03:21:53 +00:00
|
|
|
|
2022-08-28 04:38:35 +00:00
|
|
|
return res;
|
|
|
|
|
});
|
2022-07-12 21:14:36 +00:00
|
|
|
}
|