초기 세팅
yarn init -y
yarn add express prisma @prisma/client cookie-parser jsonwebtoken
yarn add -D nodemon
npx prisma init
.prettierrc 설정
yarn add prettier -D
.prettierrc.json 기본 설정
{
"printWidth": 80,
"tabWidth": 2,
"singleQuote": false,
"trailingComma": "all"
}
package.json에 script 추가
"scripts": {
"format": "prettier --write *.js **/*.js"
},
yarn run format
nodemone 이용하여 서버 실행
"scripts": {
"dev": "nodemon api.js"
},
schema.prisma 작성
model Users {
userId Int @id @default(autoincrement()) @map("userId")
email String @unique @map("email")
password String @map("password")
confirmpassword String @map("confirmpassword")
name String @map("name")
resumes Resumes[]
@@map("Users")
}
model Resumes {
resumeId Int @id @default(autoincrement()) @map("resumeId")
userId Int @map("userId")
title String @map("title")
content String @map("content") @db.Text
author String @map("author")
status Status @default(APPLY)
createdAt DateTime @default(now()) @map("createdAt")
updatedAt DateTime @updatedAt @map("updatedAt")
user Users @relation(fields: [userId], references: [userId], onDelete: Cascade)
@@map("Resumes")
}
enum Status {
APPLY
DROP
PASS
INTERVIEW1
INTERVIEW2
FINAL_PASS
}
model RefreshToken {
refreshtoken String @id @map("refreshtoken")
@@map("RefreshToken")
}
테이블과 컬럼들을 생성해주고, Users 와 Resumes를 1:N관계 설정해주었다.
API 명세서 작성


ERD 작성


위의 ERROR와 비슷하게 yarn run dev 실행 시 node api.js가 실행되지 않았다.
여러가지 방법을 찾아보며 했지만 문제해결을 하지 못해서 튜터님께 질문을 했는데,
바로 api.js의 오타였다..
"scripts": {
"dev": "nodemon api.js"
},
위의 scripts를 추가했어야하는데 강의를 참고하여 하다보니 app.js로 오타를 내서 서버가 실행이 되지 않았던것이였다..
1시간 넘게 error를 찾아보고 수정하고 다시 만들고 여러가지 했지만 안되었던 점이 오타라니..
이런 실수를 겪고 나니 다른 코드 작성 시 오타가 나지 않도록 더더욱 신경을 써서 작성했다!