-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1319 from Jhaemis-hack/dev
"FEAT: Implement Product Review and Star Rating Feature"
- Loading branch information
Showing
15 changed files
with
210 additions
and
103 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,33 @@ | ||
NODE_ENV=development | ||
PROFILE=local | ||
PORT=5000 | ||
HOST= | ||
REDIS_PORT= 6379 | ||
DB_SSL=true | ||
NODE_ENV=development | ||
|
||
PORT=3008 | ||
|
||
JWT_SECRET=someSecrets | ||
JWT_EXPIRY_TIMEFRAME=3600 | ||
|
||
|
||
REDIS_HOST=localhost | ||
REDIS_PORT=6379 | ||
DB_TYPE= | ||
|
||
DB_TYPE=postgres | ||
DB_USERNAME= | ||
DB_PASSWORD= | ||
DB_HOST= | ||
DB_NAME=hng | ||
DB_HOST=localhost | ||
DB_DATABASE= | ||
DB_ENTITIES=dist/src/modules/**/entities/**/*.entity{.ts,.js} | ||
DB_MIGRATIONS=dist/db/migrations/*{.ts,.js} | ||
POSGRES_USER=$DB_USERNAME | ||
POST | ||
JWT_SECRET=gsgs | ||
JWT_EXPIRY_TIMEFRAME=1500000 | ||
DB_SSL=false | ||
JWT_REFRESH_SECRET=bbp | ||
JWT_REFRESH_EXPIRY_TIMEFRAME=15 | ||
GOOGLE_REDIRECT_URI= | ||
|
||
JWT_SECRET=someSecrets | ||
JWT_EXPIRY_TIMEFRAME=3600 | ||
|
||
ADMIN_SECRET_KEY=sometext | ||
|
||
GOOGLE_CLIENT_SECRET= | ||
GOOGLE_CLIENT_ID= | ||
OAUTH_LOGIN_REDIRECT= | ||
SMTP_HOST= | ||
|
||
SMTP_HOST=sandbox.smtp.mailtrap.io | ||
SMTP_PORT=587 | ||
SERVER_NAME=Boilerplate | ||
SERVER_NAME=api | ||
SMTP_USER= | ||
SMTP_PASSWORD= | ||
FRONTEND_URL= | ||
ADMIN_SECRET= | ||
SUPPORT_EMAIL= | ||
AUTH_PASSWORD= | ||
BASE_URL= | ||
FLUTTERWAVE_SECRET_KEY= | ||
FLUTTERWAVE_BASE_URL= | ||
SMTP_PASSWORD= |
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createParamDecorator, ExecutionContext } from '@nestjs/common'; | ||
|
||
export const CurrentUser = createParamDecorator((data: unknown, ctx: ExecutionContext) => { | ||
const request = ctx.switchToHttp().getRequest(); | ||
return request.user; // This works if AuthGuard attaches user object to request | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { IsInt, IsString, Max, Min } from 'class-validator'; | ||
|
||
export class CreateReviewDto { | ||
@IsInt() | ||
@Min(1) | ||
@Max(5) | ||
rating: number; | ||
|
||
@IsString() | ||
review: string; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
export class ProductResponseDto { | ||
id: string; | ||
name: string; | ||
description: string; | ||
averageRating: number; | ||
totalReviews: number; | ||
|
||
@ApiProperty({ type: () => [ReviewSummaryDto] }) | ||
recentReviews: ReviewSummaryDto[]; | ||
} | ||
|
||
// Define ReviewSummaryDto **inside the same file**, avoiding unnecessary imports | ||
class ReviewSummaryDto { | ||
rating: number; | ||
review: string; | ||
createdBy: string; | ||
createdAt: Date; | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, CreateDateColumn, UpdateDateColumn } from 'typeorm'; | ||
import { Product } from './product.entity'; | ||
|
||
@Entity() | ||
export class Review { | ||
@PrimaryGeneratedColumn('uuid') | ||
id: string; | ||
|
||
@Column({ type: 'int', width: 1 }) | ||
rating: number; | ||
|
||
@Column({ type: 'text' }) | ||
review: string; | ||
|
||
@Column() | ||
createdBy: string; // This will be user ID | ||
|
||
@ManyToOne(() => Product, product => product.reviews, { onDelete: 'CASCADE' }) | ||
product: Product; | ||
|
||
@CreateDateColumn() | ||
createdAt: Date; | ||
|
||
@UpdateDateColumn() | ||
updatedAt: Date; | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.