2022-08-26 07:20:30 +02:00
|
|
|
import { prisma, runQuery } from 'lib/relational';
|
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) {
|
|
|
|
return runQuery(
|
|
|
|
prisma.website.create({
|
|
|
|
data: {
|
|
|
|
account: {
|
|
|
|
connect: {
|
|
|
|
user_id,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
...data,
|
|
|
|
},
|
|
|
|
}),
|
2022-08-27 05:21:53 +02:00
|
|
|
).then(async res => {
|
|
|
|
if (process.env.REDIS_URL) {
|
|
|
|
await redis.set(`website:${res.website_uuid}`, Number(res.website_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
});
|
2022-07-12 23:14:36 +02:00
|
|
|
}
|