2022-08-28 06:38:35 +02:00
|
|
|
import prisma from 'lib/prisma';
|
2022-08-27 05:21:53 +02:00
|
|
|
import redis from 'lib/redis';
|
2022-07-12 23:14:36 +02:00
|
|
|
|
|
|
|
export async function createWebsite(user_id, data) {
|
2022-08-28 06:38:35 +02:00
|
|
|
return prisma.client.website
|
|
|
|
.create({
|
2022-07-12 23:14:36 +02:00
|
|
|
data: {
|
|
|
|
account: {
|
|
|
|
connect: {
|
|
|
|
user_id,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
...data,
|
|
|
|
},
|
2022-08-28 06:38:35 +02:00
|
|
|
})
|
|
|
|
.then(async res => {
|
2022-08-29 22:04:58 +02:00
|
|
|
if (redis.client && res) {
|
2022-08-31 00:54:33 +02:00
|
|
|
await redis.client.set(`website:${res.website_uuid}`, res.website_id);
|
2022-08-28 06:38:35 +02:00
|
|
|
}
|
2022-08-27 05:21:53 +02:00
|
|
|
|
2022-08-28 06:38:35 +02:00
|
|
|
return res;
|
|
|
|
});
|
2022-07-12 23:14:36 +02:00
|
|
|
}
|