mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-03 15:47:30 +01:00
33 lines
583 B
TypeScript
33 lines
583 B
TypeScript
import { Website } from '@prisma/client';
|
|
import cache from 'lib/cache';
|
|
import prisma from 'lib/prisma';
|
|
|
|
export async function createWebsite(
|
|
userId: string,
|
|
data: {
|
|
id: string;
|
|
name: string;
|
|
domain: string;
|
|
shareId?: string;
|
|
},
|
|
): Promise<Website> {
|
|
return prisma.client.website
|
|
.create({
|
|
data: {
|
|
user: {
|
|
connect: {
|
|
id: userId,
|
|
},
|
|
},
|
|
...data,
|
|
},
|
|
})
|
|
.then(async data => {
|
|
if (cache.enabled) {
|
|
await cache.storeWebsite(data);
|
|
}
|
|
|
|
return data;
|
|
});
|
|
}
|