Skip to content
Open
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
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Node.js 기본
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# 환경 변수 파일
.env

# Prisma 관련
prisma/.env

# OS별 임시 파일
.DS_Store
Thumbs.db

# 기타 IDE/Editor 설정 파일
.vscode/
.idea/
.cursor/
*.swp

test.request/
15 changes: 15 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as dotenv from "dotenv";
import express from "express";
import cors from "cors";
import router from "./routes/index.js";
dotenv.config();

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

app.use("/", router);

const port = process.env.PORT || 3000;

app.listen(port, () => console.log(`Server Started :${port}`));
29 changes: 29 additions & 0 deletions mock/mock.product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export const PRODUCTS = [
{
id: "f8013040-b076-4dc4-8677-11be9a17162f",
title: "title01",
price: 1004,
description: "상품 설명",
tags: ["item", "sprint", "codeit"],
imgUrl:
"https://cdn.thepowernews.co.kr/news/photo/202306/124945_228995_3557.jpg",
},
{
id: "d2ff3048-83bc-425a-8ad3-d6d9af1c7c6d",
title: "title02",
price: 1004,
description: "상품 설명",
tags: ["item", "sprint", "codeit"],
imgUrl:
"https://cdn.thepowernews.co.kr/news/photo/202306/124945_228995_3557.jpg",
},
{
id: "7f70481b-784d-4b0e-bc3e-f05eefc17951",
title: "title03",
price: 1004,
description: "상품 설명",
tags: ["item", "sprint", "codeit"],
imgUrl:
"https://cdn.thepowernews.co.kr/news/photo/202306/124945_228995_3557.jpg",
},
];
25 changes: 25 additions & 0 deletions mock/seed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { PrismaClient } from "@prisma/client";
import { PRODUCTS } from "./mock.product.js";
const prisma = new PrismaClient();

async function main() {
// 기존 데이터 삭제
await prisma.products.deleteMany();

// 목 데이터 삽입
await prisma.products.createMany({
data: PRODUCTS,
skipDuplicates: true,
});
}

main()
.then(async () => {
await prisma.$disconnect();
console.log("success");
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});
Loading