mirror of
https://github.com/SrIzan10/hctv.git
synced 2026-06-06 00:56:56 +00:00
feat: move to pnpm and implement db repo
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -39,4 +39,5 @@ next-env.d.ts
|
||||
certificates
|
||||
dev/psql
|
||||
|
||||
.turbo
|
||||
.turbo
|
||||
packages/db/generated/client
|
||||
@@ -3,25 +3,23 @@
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "docker compose --file ../../dev/docker-compose.yml up -d && next dev --turbo",
|
||||
"dd": "docker compose --file ../../dev/docker-compose.yml up -d",
|
||||
"dev": "next dev",
|
||||
"donly": "docker compose --file ../../dev/docker-compose.yml up",
|
||||
"setup": "docker compose --file ../../dev/docker-compose.yml up -d && prisma migrate deploy",
|
||||
"build": "prisma generate && next build",
|
||||
"start": "prisma migrate deploy && next start",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"db:generate": "prisma generate",
|
||||
"db:migrate": "prisma migrate dev --name",
|
||||
"ui:add": "shadcn add",
|
||||
"prepare": "next-ws patch",
|
||||
"act": "act --secret-file .env.ci",
|
||||
"check-types": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hctv/db": "workspace:*",
|
||||
"@hookform/resolvers": "^3.9.1",
|
||||
"@livekit/components-react": "^2.7.0",
|
||||
"@lucia-auth/adapter-prisma": "^4.0.1",
|
||||
"@node-rs/argon2": "^2.0.2",
|
||||
"@prisma/client": "^6.0.1",
|
||||
"@radix-ui/react-avatar": "^1.0.4",
|
||||
"@radix-ui/react-dialog": "^1.1.5",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
||||
@@ -66,10 +64,8 @@
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "15.1.3",
|
||||
"postcss": "^8",
|
||||
"prisma": "^6.0.1",
|
||||
"shadcn": "^2.1.8",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"typescript": "^5"
|
||||
},
|
||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/db';
|
||||
import prisma from '@hctv/db';
|
||||
import { NextRequest } from 'next/server';
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { lucia } from '@/lib/auth';
|
||||
import prisma from '@/lib/db';
|
||||
import prisma from '@hctv/db';
|
||||
import { resolveUserPersonalChannel } from '@/lib/db/resolve';
|
||||
import type { WebSocket } from 'ws';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { validateRequest } from '@/lib/auth';
|
||||
import prisma from '@/lib/db';
|
||||
import prisma from '@hctv/db';
|
||||
import { NextRequest } from 'next/server';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import db from '@/lib/db';
|
||||
import db from '@hctv/db';
|
||||
import { resolveChannelNameId } from '@/lib/db/resolve';
|
||||
|
||||
export async function GET(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { validateRequest } from '@/lib/auth';
|
||||
import prisma from '@/lib/db';
|
||||
import prisma from '@hctv/db';
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { slack, lucia } from '@/lib/auth';
|
||||
import { cookies as nextCookies } from 'next/headers';
|
||||
import { decodeIdToken, OAuth2RequestError } from 'arctic';
|
||||
import { generateIdFromEntropySize } from 'lucia';
|
||||
import prisma from '@/lib/db';
|
||||
import prisma from '@hctv/db';
|
||||
|
||||
export async function GET(request: Request): Promise<Response> {
|
||||
const cookies = await nextCookies();
|
||||
|
||||
@@ -2,7 +2,7 @@ import LandingPage from '@/components/app/LandingPage/LandingPage';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import ConfusedDino from '@/components/ui/confuseddino';
|
||||
import { validateRequest } from '@/lib/auth';
|
||||
import prisma from '@/lib/db';
|
||||
import prisma from '@hctv/db';
|
||||
import { Avatar, AvatarImage, AvatarFallback } from '@radix-ui/react-avatar';
|
||||
import Image from 'next/image';
|
||||
import Link from 'next/link';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { validateRequest } from '@/lib/auth';
|
||||
import prisma from '@/lib/db';
|
||||
import prisma from '@hctv/db';
|
||||
import EditLivestreamDialog from './dialog';
|
||||
|
||||
export default async function EditLivestream() {
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '@/components/ui/dialog';
|
||||
import { StreamInfo } from '@prisma/client';
|
||||
import { StreamInfo } from '@hctv/db';
|
||||
import { UniversalForm } from '../UniversalForm/UniversalForm';
|
||||
import { editStreamInfo } from '@/lib/form/actions';
|
||||
import RegenerateKey from '../RegenerateKey/RegenerateKey';
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import type { Channel } from '@prisma/client';
|
||||
import type { Channel } from '@hctv/db';
|
||||
import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar';
|
||||
import useSWR, { Fetcher } from 'swr';
|
||||
import { fetcher } from '@/lib/services/swr';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import StreamPlayer from '../StreamPlayer/StreamPlayer';
|
||||
import UserInfoCard from '../UserInfoCard/UserInfoCard';
|
||||
import ChatPanel from '../ChatPanel/ChatPanel';
|
||||
import type { StreamInfo, User } from '@prisma/client';
|
||||
import type { StreamInfo, User } from '@hctv/db';
|
||||
import { useIsMobile } from '@/lib/hooks/useMobile';
|
||||
|
||||
export default function LiveStream(props: Props) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Avatar, AvatarImage } from '@/components/ui/avatar';
|
||||
import type { StreamInfo, User } from '@prisma/client';
|
||||
import type { StreamInfo, User } from '@hctv/db';
|
||||
import FollowButton from './follow';
|
||||
import FollowCountText from './followCount';
|
||||
import ViewerCount from './viewerCount';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PrismaAdapter } from '@lucia-auth/adapter-prisma';
|
||||
import { Lucia } from 'lucia';
|
||||
import prisma from '../db';
|
||||
import prisma from '@hctv/db';
|
||||
import { cache } from 'react';
|
||||
import { cookies } from 'next/headers';
|
||||
import { Slack } from 'arctic';
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
|
||||
const prismaClientSingleton = () => {
|
||||
return new PrismaClient()
|
||||
}
|
||||
|
||||
declare global {
|
||||
var prismaGlobal: undefined | ReturnType<typeof prismaClientSingleton>
|
||||
}
|
||||
|
||||
const prisma = globalThis.prismaGlobal ?? prismaClientSingleton()
|
||||
|
||||
export default prisma
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma
|
||||
@@ -1,4 +1,4 @@
|
||||
import db from '@/lib/db';
|
||||
import db from '@hctv/db';
|
||||
|
||||
export async function resolveChannelNameId(channelName: string) {
|
||||
const channel = await db.channel.findUnique({
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { validateRequest } from '../auth';
|
||||
import prisma from '../db';
|
||||
import prisma from '@hctv/db';
|
||||
import zodVerify from '../zodVerify';
|
||||
import { onboardSchema, streamInfoEditSchema } from './zod';
|
||||
import { initializeStreamInfo } from '../instrumentation/streamInfo';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import prisma from '@/lib/db';
|
||||
import prisma from '@hctv/db';
|
||||
import { HttpFlv } from '../types/liveBackendJson';
|
||||
|
||||
export default async function runner() {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { createContext, useContext, ReactNode } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import { Channel, StreamInfo } from '@prisma/client'
|
||||
import type { Channel, StreamInfo } from '@hctv/db'
|
||||
import { fetcher } from '../services/swr'
|
||||
|
||||
const StreamContext = createContext<{
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
"devDependencies": {
|
||||
"turbo": "^2.4.4"
|
||||
},
|
||||
"packageManager": "bun@1.2.5"
|
||||
"packageManager": "pnpm@10.6.5"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"name": "@hctv/db",
|
||||
"version": "1.0.0",
|
||||
"version": "0.0.0",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prisma/client": "^6.5.0",
|
||||
"prisma": "^6.5.0"
|
||||
@@ -10,4 +13,4 @@
|
||||
"db:migrate": "prisma migrate dev",
|
||||
"db:deploy": "prisma migrate deploy"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../generated/client"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
|
||||
8
packages/db/src/client.ts
Normal file
8
packages/db/src/client.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { PrismaClient } from "../generated/client";
|
||||
|
||||
const globalForPrisma = global as unknown as { prisma: PrismaClient };
|
||||
|
||||
export const prisma =
|
||||
globalForPrisma.prisma || new PrismaClient();
|
||||
|
||||
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
|
||||
7
packages/db/src/index.ts
Normal file
7
packages/db/src/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// from https://www.prisma.io/docs/guides/turborepo
|
||||
|
||||
import { prisma } from './client'
|
||||
|
||||
export { prisma } from './client' // exports instance of prisma
|
||||
export * from "../generated/client" // exports generated types from prisma
|
||||
export default prisma;
|
||||
7333
pnpm-lock.yaml
generated
Normal file
7333
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
3
pnpm-workspace.yaml
Normal file
3
pnpm-workspace.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
packages:
|
||||
- packages/*
|
||||
- apps/*
|
||||
15
turbo.json
15
turbo.json
@@ -2,13 +2,26 @@
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"tasks": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"dependsOn": ["^db:generate", "^build"],
|
||||
"outputs": [".next/**", "!.next/cache/**"]
|
||||
},
|
||||
"setup": {
|
||||
"dependsOn": ["^dd", "^db:generate", "^build"],
|
||||
"outputs": [".next/**", "!.next/cache/**"]
|
||||
},
|
||||
"start": {
|
||||
"dependsOn": ["^dd", "^db:generate", "^build"],
|
||||
"outputs": [".next/**", "!.next/cache/**"]
|
||||
},
|
||||
"check-types": {
|
||||
"dependsOn": ["^check-types"]
|
||||
},
|
||||
"dev": {
|
||||
"dependsOn": ["^dd", "db:generate"],
|
||||
"persistent": true,
|
||||
"cache": false
|
||||
},
|
||||
"dd": {
|
||||
"persistent": true,
|
||||
"cache": false
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user