Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 46 additions & 0 deletions .github/workflows/pr-description.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PR Description Generator

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
update-pr-description:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Generate PR description
id: generate-description
run: |
# Get commits between base and head
COMMITS=$(git log --pretty=format:"- %s%n %b" ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | sed '/^[[:space:]]*$/d')

# Create description with markdown
echo "# Changes in this Pull Request" > pr_description.md
echo "" >> pr_description.md
echo "## Commit History" >> pr_description.md
echo "" >> pr_description.md
echo "$COMMITS" >> pr_description.md

# If PR already has a description, preserve it after a separator
if [ ! -z "${{ github.event.pull_request.body }}" ]; then
echo "" >> pr_description.md
echo "---" >> pr_description.md
echo "## Original Description" >> pr_description.md
echo "" >> pr_description.md
echo "${{ github.event.pull_request.body }}" >> pr_description.md
fi

- name: Update PR Description
run: |
gh pr edit ${{ github.event.pull_request.number }} --body-file pr_description.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions package-lock.json

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

25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,31 @@
"description": "",
"dependencies": {
"@prisma/client": "^5.22.0",
"bcrypt": "^5.1.1",
"cors": "^2.8.5",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.2",
"pg": "^8.11.3",
"cors": "^2.8.5",
"socket.io": "^4.7.4",
"bcrypt": "^5.1.1",
"jsonwebtoken": "^9.0.2"
"socket.io": "^4.7.4"
},
"devDependencies": {
"@faker-js/faker": "^9.5.0",
"@types/bcrypt": "^5.0.2",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.5",
"@types/node": "^20.11.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"@types/pg": "^8.10.9",
"@types/cors": "^2.8.17",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"@types/socket.io": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"eslint": "^8.56.0",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
"prettier": "^3.2.5",
"@types/socket.io": "^3.0.2",
"prisma": "^5.22.0",
"@types/bcrypt": "^5.0.2",
"@types/jsonwebtoken": "^9.0.5"
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"lint-staged": {
"*.ts": [
Expand Down
14 changes: 14 additions & 0 deletions prisma/migrations/20250216180921_add_category_table/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- CreateTable
CREATE TABLE "Category" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"slug" TEXT NOT NULL,
"description" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Category_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Category_slug_key" ON "Category"("slug");
39 changes: 39 additions & 0 deletions prisma/migrations/20250216182927_add_items/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
-- CreateTable
CREATE TABLE "Item" (
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL,
"description" TEXT,
"startPrice" DECIMAL(10,2) NOT NULL,
"currentBid" DECIMAL(10,2),
"retailPrice" DECIMAL(10,2) NOT NULL,
"imageUrl" TEXT NOT NULL,
"endTime" TIMESTAMP(3) NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,

CONSTRAINT "Item_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "_ItemCategories" (
"A" INTEGER NOT NULL,
"B" INTEGER NOT NULL
);

-- CreateIndex
CREATE INDEX "Item_endTime_idx" ON "Item"("endTime");

-- CreateIndex
CREATE INDEX "Item_createdAt_idx" ON "Item"("createdAt");

-- CreateIndex
CREATE UNIQUE INDEX "_ItemCategories_AB_unique" ON "_ItemCategories"("A", "B");

-- CreateIndex
CREATE INDEX "_ItemCategories_B_index" ON "_ItemCategories"("B");

-- AddForeignKey
ALTER TABLE "_ItemCategories" ADD CONSTRAINT "_ItemCategories_A_fkey" FOREIGN KEY ("A") REFERENCES "Category"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_ItemCategories" ADD CONSTRAINT "_ItemCategories_B_fkey" FOREIGN KEY ("B") REFERENCES "Item"("id") ON DELETE CASCADE ON UPDATE CASCADE;
22 changes: 22 additions & 0 deletions prisma/migrations/20250218043544_create_bid_model/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- CreateTable
CREATE TABLE "Bid" (
"id" SERIAL NOT NULL,
"amount" DECIMAL(10,2) NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"itemId" INTEGER NOT NULL,
"userId" INTEGER NOT NULL,

CONSTRAINT "Bid_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "Bid_itemId_idx" ON "Bid"("itemId");

-- CreateIndex
CREATE INDEX "Bid_userId_idx" ON "Bid"("userId");

-- AddForeignKey
ALTER TABLE "Bid" ADD CONSTRAINT "Bid_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "Item"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Bid" ADD CONSTRAINT "Bid_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
42 changes: 42 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,46 @@ model User {
marketingEmails Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
bids Bid[]
}

model Category {
id Int @id @default(autoincrement())
name String
slug String @unique
description String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
items Item[] @relation("ItemCategories")
}

model Item {
id Int @id @default(autoincrement())
title String
description String?
startPrice Decimal @db.Decimal(10, 2)
currentBid Decimal? @db.Decimal(10, 2)
retailPrice Decimal @db.Decimal(10, 2)
imageUrl String
endTime DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
categories Category[] @relation("ItemCategories")
bids Bid[]

@@index([endTime])
@@index([createdAt])
}

model Bid {
id Int @id @default(autoincrement())
amount Decimal @db.Decimal(10, 2)
createdAt DateTime @default(now())
item Item @relation(fields: [itemId], references: [id])
itemId Int
user User @relation(fields: [userId], references: [id])
userId Int

@@index([itemId])
@@index([userId])
}
6 changes: 5 additions & 1 deletion prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { PrismaClient } from '@prisma/client';
import { UserSeeder } from './seeders/UserSeeder';
import { seedCategories } from './seeders/CategorySeeder';
import { seedItems } from './seeders/ItemSeeder';

const prisma = new PrismaClient();

async function main() {
console.log('🌱 Starting seeding...');

// Run seeders
// Run seeders in order
await new UserSeeder(prisma).run();
await seedCategories();
await seedItems();

console.log('✅ Seeding completed');
}
Expand Down
46 changes: 46 additions & 0 deletions prisma/seeders/CategorySeeder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import prisma from '../../src/lib/prisma';

export async function seedCategories() {
const categories = [
{
name: 'Electronics',
slug: 'electronics',
description: 'Phones, laptops, tablets, and other electronic devices',
},
{
name: 'Home & Garden',
slug: 'home-garden',
description: 'Furniture, decor, and outdoor equipment',
},
{
name: 'Fashion',
slug: 'fashion',
description: 'Clothing, shoes, and accessories',
},
{
name: 'Sports',
slug: 'sports',
description: 'Sports equipment and athletic gear',
},
{
name: 'Collectibles',
slug: 'collectibles',
description: 'Rare items, antiques, and memorabilia',
},
{
name: 'Vehicles',
slug: 'vehicles',
description: 'Cars, motorcycles, and automotive parts',
},
];

for (const category of categories) {
await prisma.category.upsert({
where: { slug: category.slug },
update: category,
create: category,
});
}

console.log('Categories seeded successfully');
}
32 changes: 32 additions & 0 deletions prisma/seeders/ItemSeeder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import prisma from '../../src/lib/prisma';
import { faker } from '@faker-js/faker';

export async function seedItems() {
const categories = await prisma.category.findMany();

// Create 25 items for each category
for (const category of categories) {
const items = Array.from({ length: 25 }, () => ({
title: faker.commerce.productName(),
description: faker.commerce.productDescription(),
startPrice: parseFloat(faker.commerce.price({ min: 10, max: 100 })),
retailPrice: parseFloat(faker.commerce.price({ min: 100, max: 1000 })),
imageUrl: `https://picsum.photos/seed/${faker.string.alphanumeric(10)}/400/400`,
endTime: faker.date.future(),
}));

for (const item of items) {
// Create item with category connection
await prisma.item.create({
data: {
...item,
categories: {
connect: [{ id: category.id }],
},
},
});
}
}

console.log('✅ Items seeded successfully');
}
Loading