Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

db schema update, added CourseDetails model and some other fields #24

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ model Session {
}

model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
role Role @default(BASIC)
accounts Account[]
sessions Session[]
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
role Role @default(BASIC)
accounts Account[]
sessions Session[]

stripeCustomerId String? @unique
stripePurchasedProducts String[]

lessonsCompleted UserLessonProgress[]
}

Expand All @@ -66,15 +70,26 @@ model VerificationToken {

// Course, Lessons and Content related data
model Course {
id String @id @default(cuid())
name String
description String
slug String @unique
imageUrl String?
parts Part[]
lessons Lesson[]
author String?
published Boolean @default(false)
id String @id @default(cuid())
name String
description String
slug String @unique
stripeProductId String? @unique
imageUrl String?
parts Part[]
lessons Lesson[]
details CourseDetails?
author String?
published Boolean @default(false)
}

model CourseDetails {
id String @id @default(cuid())
course Course @relation(fields: [courseId], references: [id])
courseId String @unique
content Bytes
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

model Part {
Expand Down
3 changes: 3 additions & 0 deletions src/components/LoadingBars.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Purely presentational UI component that shows DaisyUI loading bars centered in its scope.
*/
const LoadingBars = () => {
return (
<div className="w-full h-full flex flex-col justify-center items-center">
Expand Down
30 changes: 30 additions & 0 deletions src/server/controllers/mdxController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { AuthenticationError, requireAdminAuth } from "../auth";

type MdxGetCompiledSourceProps = {
courseSlug: string;
partSlug?: string;
lessonSlug?: string;
access: "PUBLIC" | "USER" | "ADMIN";
}
/**
* WIP
*/
const mdxGetCompiledSource = async ({
courseSlug, partSlug, lessonSlug, access
}: MdxGetCompiledSourceProps) => {
try {
await requireAdminAuth();





return;
} catch (error) {

if (error instanceof AuthenticationError) {
throw error; // Rethrow custom error as-is
}
throw new Error("An error occurred while fetching courses.");
}
}