Blogging application - #9
Open
SRIRAM-PURANIK wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack
Next.js 16 (App Router), TypeScript, Prisma with SQLite, Tailwind CSS. Auth is custom: bcryptjs for password hashing, jose for JWTs stored in httpOnly cookies.
Features
Design decisions
Slug uniqueness is scoped per author using @@unique([authorId, slug]) rather than being global. Post URLs are /username/slug, so two users can both have a post titled "Hello World" without collision. If the same author reuses a title, the slug gets a numeric suffix.
Public pages are server components that query the database directly, so there is no client-side fetching for content. Only the interactive parts like forms and delete buttons are client components.
Authorization is checked server-side. Delete buttons are conditionally rendered, but the real permission check is in the API route, since hiding a button is not security.
Every mutation looks the record up by ID and then verifies the owner ID from the JWT before acting. Post edit and delete return 404 instead of 403 on an ownership mismatch, so the response does not reveal whether a post exists.
Setup
npm install
npx prisma migrate dev
npm run dev
Needs a .env file with DATABASE_URL="file:./dev.db" and a JWT_SECRET.
Not implemented
The extra credit items were not attempted. I focused on completing all the core requirements first.