This is a backend server application built with Node.js, Express, and Prisma ORM. The application provides authentication and authorization services with role-based access control (ADMIN, COMPANY, USER). It includes features like user registration, login, profile management, and password management.
-
Authentication & Authorization
- User registration with role-based accounts (Admin, Company, User)
- Secure login with JWT authentication
- Role-based access control
- Token refresh mechanism
- Password change functionality
-
Security
- Password hashing with bcrypt
- JWT token-based authentication
- HTTP-only cookies for refresh tokens
-
Error Handling
- Global error handling middleware
- Custom error classes
- Validation using Zod
-
Database
- Prisma ORM for database operations
- Transaction support for data integrity
A powerful review management platform with comprehensive API for creating, managing, and interacting with reviews.
- User Authentication - Secure signup and login functionality
- Review Management - Create, read, update, and delete reviews
- Categorization - Organize reviews by categories
- Comments - Allow users to comment on reviews
- Voting System - Upvote or downvote reviews
- Premium Content - Monetize premium reviews with payment integration
- Admin Controls - Moderation tools for review approval
- Backend: Node.js, Express.js
- Language: TypeScript
- Database: PostgreSQL.
- ORM: Prisma
- Authentication: JWT (JSON Web Tokens)
- Deployment: Render
Base URL: https://assignment-9-server-7r96.onrender.com/api
I'll create an enhanced version of your README with better organization, formatting, and visual appeal.
...Request Body:
{
"name": "John Doe",
"email": "john@example.com",
"password": "securePassword123"
}POST /auth/login
Request Body:
{
"email": "john@example.com",
"password": "securePassword123"
}POST /category/create-category
Request Body:
{
"name": "Gadgets"
}Headers:
Authorization: Bearer {admin_token}
GET /category
GET /category/{categoryId}
POST /review/create-review
Request Body:
{
"title": "Amazing Noise Cancelling Headphones",
"description": "These headphones provide crystal clear sound and outstanding noise cancellation. Battery life is also impressive with over 30 hours of playback.",
"rating": 5,
"purchaseSource": "BestBuy",
"imageUrls": [
"https://example.com/images/headphone-front.jpg",
"https://example.com/images/headphone-side.jpg"
],
"excerp": "Top-notch noise cancelling headphones with long battery life.",
"isPremium": true,
"price": 7.99,
"isPublished": false,
"categoryId": "8b00f961-4a54-4419-bd37-bf149d163e34"
}Headers:
Authorization: Bearer {user_token}
GET /review
Query Parameters:
searchTerm- Search by textpage- Page number for paginationlimit- Items per pagecategoryId- Filter by categoryisPaid- Filter by payment status (true/false/"")isPublished- Filter by publication status (true/false/"")
GET /review/{reviewId}
Headers:
Authorization: Bearer {user_token}
GET /review/my-reviews
Headers:
Authorization: Bearer {user_token}
GET /review/pending-reviews
Headers:
Authorization: Bearer {admin_token}
PATCH /review/make-review-published/{reviewId}
Headers:
Authorization: Bearer {admin_token}
PATCH /review/update-review/{reviewId}
Headers:
Authorization: Bearer {user_token}(must be review owner)
DELETE /review/delete-review/{reviewId}
Headers:
Authorization: Bearer {user_token}(must be review owner or admin)
POST /comment/create-comment
Request Body:
{
"content": "This review was very helpful, thank you!",
"reviewId": "de71f985-3a61-4a28-8d05-ad258d656bff"
}Headers:
Authorization: Bearer {user_token}
GET /comment/my-comments
Headers:
Authorization: Bearer {user_token}
POST /vote/create-vote
Request Body:
{
"type": "UP",
"reviewId": "de71f985-3a61-4a28-8d05-ad258d656bff"
}Note: A user can vote on a review only once. Valid vote types are "UP" or "DOWN".
Headers:
Authorization: Bearer {user_token}
GET /vote/my-votes
Headers:
Authorization: Bearer {user_token}
POST /payment/make-order/{reviewId}
Note: A user can purchase a premium review only once.
Headers:
Authorization: Bearer {user_token}
GET /payment/my-payments
Headers:
Authorization: Bearer {user_token}
- Clone the repository
git clone https://github.com/HumayunKabirSobuj/ReviewHub-Server.git
cd ReviewHub-Server
- Install dependencies
npm install
- Set up environment variables
Create a
.envfile in the root directory (see Environment Variables section) - Run the development server
npm run dev
Create a .env file in the root directory with the following variables:
# Database
DATABASE_URL=your_supabase_api_link
DIRECT_URL=your_supabase_direct_url
# API
VITE_API_LINk=your_api_link
PORT=5000
ENABLE_PRISMA_CACHING=false
# Authentication
JWT_SECRET=your_jwt_secret
EXPIRES_IN=1d
REFRESH_TOKEN_SECRET=your_refresh_token_secret
REFRESH_TOKEN_EXPIRES_IN=7d
JWT_REFRESH_SECRET=your_jwt_refresh_secret
JWT_REFRESH_EXPIRES_IN=7d
# URLs
BACKEND_API_LINK=your_backend_live_api_link
CLIENT_LINK=your_frontend_live_link
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.