Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: finish profile route api route with database calls #30

Merged
merged 6 commits into from
Dec 14, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ To learn more about Next.js, take a look at the following resources:
- [ShadCN](https://shadcn.com/) - UI components
- [better-auth](https://better-auth.com/) - Authentication
- [prisma](https://prisma.io/) - Database ORM
- [pino](https://github.com/pinojs/pino) - Logging

## 🚧 Commit Message Guidelines

Expand Down
Binary file modified bun.lockb
Binary file not shown.
8 changes: 6 additions & 2 deletions next.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import type { NextConfig } from 'next';
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
output: 'standalone',
output: "standalone",
serverExternalPackages: ["pino", "pino-pretty"],
experimental: {
typedRoutes: true,
},
};

export default nextConfig;
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,38 @@
"private": true,
"scripts": {
"dev": "next dev --turbopack",
"build": "next build",
"build": "prisma generate && next build",
"start": "next start",
"lint": "eslint .",
"lint:fix": "eslint \"**/*.{ts,tsx}\" --fix",
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
"format": "prettier --write .",
"prepare": "husky"
},
"dependencies": {
"@prisma/client": "^6.0.1",
"@scalar/nextjs-api-reference": "^0.4.105",
"@tanstack/react-query": "^5.60.5",
"@types/jstoxml": "^2.0.4",
"better-auth": "^1.0.18",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"dotenv": "^16.4.5",
"dotenv-expand": "^12.0.1",
"jstoxml": "^5.0.2",
"lucide-react": "^0.460.0",
"next": "15.0.4",
"pg": "^8.13.1",
"pino": "^9.5.0",
"pino-pretty": "^13.0.0",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.8",
"react": "19.0.0",
"react-dom": "19.0.0",
"sharp": "^0.33.5",
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.23.8"
"zod": "^3.23.8",
"zod-prisma-types": "^3.2.1"
},
"devDependencies": {
"@antfu/eslint-config": "^3.9.1",
Expand Down
23 changes: 16 additions & 7 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
Expand All @@ -9,6 +8,10 @@ generator client {
previewFeatures = ["views"]
}

// generator zod {
// provider = "zod-prisma-types"
// }

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
Expand Down Expand Up @@ -129,7 +132,7 @@ model Profile {
name String
profileImage String? @map("profile_image")
dateOfBirth DateTime @map("date_of_birth")
language String
language String @default("en")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
account NetflixAccount @relation(fields: [accountId], references: [id], onDelete: Cascade)
Expand Down Expand Up @@ -182,16 +185,22 @@ model ViewingHistory {
profile Profile @relation(fields: [profileId], references: [id], onDelete: Cascade)
content Content @relation(fields: [contentId], references: [id], onDelete: Cascade)

createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")

@@index([profileId])
@@index([contentId])
}

model Watchlist {
id String @id @default(uuid())
profileId String @map("profile_id")
contentId String @map("content_id")
profile Profile @relation(fields: [profileId], references: [id], onDelete: Cascade)
content Content @relation(fields: [contentId], references: [id], onDelete: Cascade)
id String @id @default(uuid())
profileId String @map("profile_id")
contentId String @map("content_id")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")

profile Profile @relation(fields: [profileId], references: [id], onDelete: Cascade)
content Content @relation(fields: [contentId], references: [id], onDelete: Cascade)

@@unique([profileId, contentId])
@@index([profileId])
Expand Down
Empty file removed src/app/api/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions src/app/api/health/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { NextRequest } from 'next/server';

import { createResponse } from '@/lib/utils';

export function GET(request: NextRequest) {
return createResponse(
{
status: 'ok',
},
request.headers.get('Accept'),
200,
);
}
51 changes: 0 additions & 51 deletions src/app/api/profiles/[id]/route.ts

This file was deleted.

84 changes: 0 additions & 84 deletions src/app/api/profiles/route.ts

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions src/app/api/v1/documentation/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ApiReference } from '@scalar/nextjs-api-reference';

const config = {
spec: {
url: '/api/openapi',
},
defaultHttpClient: {
targetKey: 'javascript',
clientKey: 'fetch',
},
};

export const GET = ApiReference(config);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading