Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
191b657
feat: implement Api for products
hay-oon Jan 16, 2025
780412e
chore: update package configuration and add product route
hay-oon Jan 16, 2025
976d039
chore: add cors dependency to package.json and package-lock.json
hay-oon Jan 16, 2025
db86415
feat: add multiple product registration examples to requests.http
hay-oon Jan 16, 2025
27564d8
chore: update MongoDB connection options
hay-oon Jan 16, 2025
7f284e5
chore: enhance MongoDB connection settings with new options
hay-oon Jan 16, 2025
522fcdc
refactor: Restructure product routes and fix getProducts function
hay-oon Jan 17, 2025
7a55f4b
refactor: simplify CORS configuration
hay-oon Jan 20, 2025
f838b77
feat: add description field in getProducts function
hay-oon Jan 20, 2025
363689f
feat: migrate from MongoDB to Prisma
hay-oon Jan 22, 2025
35cd07e
feat: Add router and controller for Articles
hay-oon Jan 23, 2025
8615a30
feat: Implement comments feature with CRUD
hay-oon Jan 23, 2025
3339b9d
feat: Add seeding
hay-oon Jan 23, 2025
b42f4ab
chore: Update build script in package.json to include Prisma commands…
hay-oon Jan 23, 2025
eb7ebb8
chore: Simplify build script in package.json by removing Prisma commands
hay-oon Jan 23, 2025
455b79b
chore: Update seed command in package.json to use experimental modules
hay-oon Jan 23, 2025
e001ac9
Add complete database migrations
hay-oon Jan 23, 2025
3e885ec
refactor: service로직 분리
hay-oon Feb 25, 2025
2c540a6
refactor: 게시글 목록 조회 정렬조건 수정
hay-oon Feb 26, 2025
f7d35d9
Merge pull request #9 from hay-oon/express-정하윤-sprint7-수정
hay-oon Feb 26, 2025
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
27 changes: 0 additions & 27 deletions .github/pull-request-template.md

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/auto-label-assign.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
.env
.DS_Store
42 changes: 0 additions & 42 deletions README.md

This file was deleted.

30 changes: 30 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import express from "express";
import dotenv from "dotenv";
import cors from "cors";
import { PrismaClient } from "@prisma/client";
import apiRoutes from "./routes/index.js";

dotenv.config();

const prisma = new PrismaClient();
const app = express();

app.use(cors());
app.use(express.json());

// Prisma 연결 테스트
prisma
.$connect()
.then(() => {
console.log("Connected to PostgreSQL database");
})
.catch((err) => {
console.error("Unable to connect to the database:", err);
});

app.use("/api", apiRoutes);

const PORT = process.env.PORT || 5005;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
34 changes: 34 additions & 0 deletions http/articles.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### 게시글 등록
POST http://localhost:5005/api/articles
Content-Type: application/json

{
"title": "테스트 게시글 제목",
"content": "테스트 게시글 내용입니다."
}

### 게시글 목록 조회 (기본)
GET http://localhost:5005/api/articles

### 게시글 목록 조회 (검색)
GET http://localhost:5005/api/articles?keyword=테스트

### 게시글 목록 조회 (최신순 정렬)
GET http://localhost:5005/api/articles?sort=recent

@articleId = 899297fe-7e63-4ba6-91f1-340b417b0d55

### 게시글 상세 조회
GET http://localhost:5005/api/articles/{{articleId}}

### 게시글 수정
PATCH http://localhost:5005/api/articles/{{articleId}}
Content-Type: application/json

{
"title": "수정된 게시글 제목",
"content": "수정된 게시글 내용입니다."
}

### 게시글 삭제
DELETE http://localhost:5005/api/articles/{{articleId}}
38 changes: 38 additions & 0 deletions http/comments.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
### 게시글 댓글 작성
@articleId = c098cff3-8482-4557-bb36-fd58fad65f1d
@productId = 05818779-505c-4af0-bfba-bc19dda89341

POST http://localhost:5005/api/articles/{{articleId}}/comments
Content-Type: application/json

{
"content": "게시글에 대한 테스트 댓글입니다."
}

### 상품 댓글 작성
POST http://localhost:5005/api/products/{{productId}}/comments
Content-Type: application/json

{
"content": "상품에 대한 테스트 댓글입니다."
}

### 게시글 댓글 목록 조회
GET http://localhost:5005/api/articles/{{articleId}}/comments


### 상품 댓글 목록 조회
GET http://localhost:5005/api/products/{{productId}}/comments

@commentId = 3f9642f6-f7b3-489b-9160-d5b278975964

### 댓글 수정
PATCH http://localhost:5005/api/comments/{{commentId}}
Content-Type: application/json

{
"content": "수정된 댓글 내용입니다."
}

### 댓글 삭제
DELETE http://localhost:5005/api/comments/{{commentId}}
36 changes: 36 additions & 0 deletions http/products.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
### 상품 등록 - 외장하드
POST http://localhost:5005/api/products
Content-Type: application/json

{
"name": "맥북 프로 16인치 M2",
"description": "2023년형 맥북 프로 16인치 M2 모델입니다",
"price": 3200000,
"tags": ["맥북", "노트북", "M2"]
}

### 상품 목록 조회 (기본)
GET http://localhost:5005/api/products

### 상품 목록 조회 (페이지네이션)
GET http://localhost:5005/api/products?page=1&limit=10

### 상품 목록 조회 (검색)
GET http://localhost:5005/api/products?keyword=갤럭시

@productId = 7cad3e36-f968-4af7-8741-36129588369f

### 상품 상세 조회
GET http://localhost:5005/api/products/{{productId}}

### 상품 수정
PATCH http://localhost:5005/api/products/{{productId}}
Content-Type: application/json

{
"price": 3500000,
"description": "2023년형 맥북 프로 16인치 M2 모델입니다"
}

### 상품 삭제
DELETE http://localhost:5005/api/products/{{productId}}
Loading