2022-08-28 06:38:35 +02:00
|
|
|
import prisma from 'lib/prisma';
|
2022-11-08 07:35:51 +01:00
|
|
|
import cache from 'lib/cache';
|
2022-07-12 23:14:36 +02:00
|
|
|
|
2022-10-10 22:42:18 +02:00
|
|
|
export async function createWebsite(userId, data) {
|
2022-08-28 06:38:35 +02:00
|
|
|
return prisma.client.website
|
|
|
|
.create({
|
2022-07-12 23:14:36 +02:00
|
|
|
data: {
|
2022-11-01 07:42:37 +01:00
|
|
|
user: {
|
2022-07-12 23:14:36 +02:00
|
|
|
connect: {
|
2022-10-10 22:42:18 +02:00
|
|
|
id: userId,
|
2022-07-12 23:14:36 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
...data,
|
|
|
|
},
|
2022-08-28 06:38:35 +02:00
|
|
|
})
|
2022-11-08 07:35:51 +01:00
|
|
|
.then(async data => {
|
|
|
|
if (cache.enabled) {
|
|
|
|
await cache.storeWebsite(data);
|
2022-08-28 06:38:35 +02:00
|
|
|
}
|
2022-08-27 05:21:53 +02:00
|
|
|
|
2022-11-08 07:35:51 +01:00
|
|
|
return data;
|
2022-08-28 06:38:35 +02:00
|
|
|
});
|
2022-07-12 23:14:36 +02:00
|
|
|
}
|