A RESTful blog API built with Express, TypeScript, Prisma, and PostgreSQL. Features user authentication, posts, comments, likes, notifications, and real-time WebSocket support.
- Runtime: Node.js + TypeScript
- Framework: Express 5
- ORM: Prisma (PostgreSQL)
- Auth: JWT + bcrypt
- File Uploads: Multer + Cloudinary
- Validation: Zod
- Real-time: WebSockets (ws)
src/
├── controllers/ # Route handler logic
├── middleware/ # Auth, error handling, etc.
├── repository/ # Database access layer
├── routes/ # Express route definitions
├── services/ # Business logic
├── lib/ # Shared utilities/config
└── index.ts # App entry point
- Clone the repo and install dependencies:
pnpm install- Create a
.envfile in the project root:
DATABASE_URL=postgresql://user:password@host:5432/dbname
JWT_SECRET=your_jwt_secret
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret- Run Prisma migrations:
pnpm prisma migrate dev- Start the dev server:
pnpm devThe server starts with nodemon and reloads on file changes.
| Model | Description |
|---|---|
| User | Auth, profile, posts, comments |
| Profile | Bio, location, pronoun, avatar |
| Post | Title, content, image, published |
| Comment | Tied to a user and a post |
| Like | One like per user per post |
| Notification | LIKE or COMMENT events per user |