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

footer component added #49

Open
wants to merge 35 commits into
base: starter
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
64a6819
navbar added
Tush786 Sep 4, 2024
47d64b5
Next-auth implemented
Tush786 Sep 4, 2024
ef71ca4
api route added
Tush786 Sep 4, 2024
ca762a7
util folder added
Tush786 Sep 4, 2024
726a17d
prisma adapter added
Tush786 Sep 4, 2024
1c922f3
made changes in json file
Tush786 Sep 6, 2024
b1c9945
write blog component added
Tush786 Sep 6, 2024
8968c46
footer categorylist and feature list component added
Tush786 Sep 6, 2024
a633004
footed component added
Tush786 Sep 6, 2024
7119566
footer updated
Tush786 Sep 6, 2024
06719b5
Merge branch 'starter' of https://github.com/Tush786/next-blog into s…
Tush786 Sep 6, 2024
5393572
category list and features component removed
Tush786 Sep 6, 2024
2cfa9cf
Revert "category list and features component removed"
Tush786 Sep 6, 2024
840877d
Revert "Merge branch 'starter' of https://github.com/Tush786/next-blo…
Tush786 Sep 6, 2024
b9bb5d3
Revert "footer categorylist and feature list component added"
Tush786 Sep 6, 2024
585ae60
Revert "category list and features component removed"
Tush786 Sep 6, 2024
b1ade85
conflict resolving
Tush786 Sep 6, 2024
ca22ac3
try to resolve conflict
Tush786 Sep 6, 2024
472970c
made changes in next latest version
Tush786 Sep 6, 2024
91fa070
react-quill package upated
Tush786 Sep 6, 2024
3d2bc18
footer component updated in this
Tush786 Sep 6, 2024
fa26e57
featured component added
Tush786 Sep 6, 2024
379ef54
categorylist added
Tush786 Sep 6, 2024
7296c28
Revert "categorylist added"
Tush786 Sep 6, 2024
dbdfd6a
Revert "categorylist added"
Tush786 Sep 6, 2024
2e4c102
Reapply "categorylist added"
Tush786 Sep 6, 2024
ba17075
categorylist conflict resolving
Tush786 Sep 6, 2024
5a86b10
cardlist updated
Tush786 Sep 6, 2024
1e52c17
menu menucategories and menupost updated
Tush786 Sep 6, 2024
1eb2021
all the frontend component added
Tush786 Sep 6, 2024
28bcb54
confli t resolve
Tush786 Sep 6, 2024
7ef6759
next auth working fine
Tush786 Sep 6, 2024
486a3c7
server side url related issue resolved
Tush786 Sep 6, 2024
6dd4c9f
made changes in categorieslist
Tush786 Sep 6, 2024
b39893f
url updated
Tush786 Sep 6, 2024
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
Prev Previous commit
Next Next commit
api route added
  • Loading branch information
Tush786 committed Sep 4, 2024
commit ef71ca489186b8fcc54e176aa39a76a29203665f
109 changes: 109 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"lint": "next lint"
},
"dependencies": {
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^5.19.1",
"bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.6",
"dotenv": "^16.4.5",
Expand All @@ -22,5 +24,8 @@
"react-dom": "18.2.0",
"swr": "^2.2.5",
"validator": "^13.12.0"
},
"devDependencies": {
"prisma": "^5.19.1"
}
}
91 changes: 91 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}

model Account {
id String @id @default(cuid()) @map("_id")
userId String
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?

user User @relation(fields: [userId], references: [id], onDelete: Cascade)

@@unique([provider, providerAccountId])
}

model Session {
id String @id @default(cuid()) @map("_id")
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model User {
id String @id @default(cuid()) @map("_id")
name String?
email String @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
Post Post[]
Comment Comment[]
}

model VerificationToken {
identifier String @id @map("_id")
token String @unique
expires DateTime

@@unique([identifier, token])
}

model Category {
id String @id @default(cuid()) @map("_id")
slug String @unique
title String
img String?
Posts Post[]
}

model Post {
id String @id @default(cuid()) @map("_id")
createdAt DateTime @default(now())
slug String @unique
title String
desc String
img String?
views Int @default(0)
catSlug String
cat Category @relation(fields: [catSlug], references: [slug])
userEmail String
user User @relation(fields: [userEmail], references: [email])
comments Comment[]
}

model Comment {
id String @id @default(cuid()) @map("_id")
createdAt DateTime @default(now())
desc String
userEmail String
user User @relation(fields: [userEmail], references: [email])
postSlug String
post Post @relation(fields: [postSlug], references: [slug])
}
6 changes: 6 additions & 0 deletions src/app/api/auth/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { authOptions } from "@/utils/auth";
import NextAuth from "next-auth";

const handler = NextAuth(authOptions);

export { handler as GET, handler as POST };
15 changes: 15 additions & 0 deletions src/app/api/categories/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import prisma from "@/utils/connect";
import { NextResponse } from "next/server";

export const GET = async () => {
try {
const categories = await prisma.category.findMany();

return new NextResponse(JSON.stringify(categories, { status: 200 }));
} catch (err) {
console.log(err);
return new NextResponse(
JSON.stringify({ message: "Something went wrong!" }, { status: 500 })
);
}
};
51 changes: 51 additions & 0 deletions src/app/api/comment/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { getAuthSession } from "@/utils/auth";
import prisma from "@/utils/connect";
import { NextResponse } from "next/server";

// GET ALL COMMENTS OF A POST
export const GET = async (req) => {
const { searchParams } = new URL(req.url);

const postSlug = searchParams.get("postSlug");

try {
const comments = await prisma.comment.findMany({
where: {
...(postSlug && { postSlug }),
},
include: { user: true },
});

return new NextResponse(JSON.stringify(comments, { status: 200 }));
} catch (err) {
// console.log(err);
return new NextResponse(
JSON.stringify({ message: "Something went wrong!" }, { status: 500 })
);
}
};

// CREATE A COMMENT
export const POST = async (req) => {
const session = await getAuthSession();

if (!session) {
return new NextResponse(
JSON.stringify({ message: "Not Authenticated!" }, { status: 401 })
);
}

try {
const body = await req.json();
const comment = await prisma.comment.create({
data: { ...body, userEmail: session.user.email },
});

return new NextResponse(JSON.stringify(comment, { status: 200 }));
} catch (err) {
console.log(err);
return new NextResponse(
JSON.stringify({ message: "Something went wrong!" }, { status: 500 })
);
}
};
22 changes: 22 additions & 0 deletions src/app/api/post/[slog]/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import prisma from "@/utils/connect";
import { NextResponse } from "next/server";

// GET SINGLE POST
export const GET = async (req, { params }) => {
const { slug } = params;

try {
const post = await prisma.post.update({
where: { slug },
data: { views: { increment: 1 } },
include: { user: true },
});

return new NextResponse(JSON.stringify(post, { status: 200 }));
} catch (err) {
console.log(err);
return new NextResponse(
JSON.stringify({ message: "Something went wrong!" }, { status: 500 })
);
}
};
Loading