Skip to content

Commit

Permalink
Merge feature/32 into develop (#41)
Browse files Browse the repository at this point in the history
* Feat: ์‹๋ฌผ ์นด๋“œ ์ƒ์„ธ ์กฐํšŒ API (#33)

* Docs: update PR template (add swagger)

* Refactor: file name kebab-case ์ ์šฉ

* Feat: plant util ํ•จ์ˆ˜

* Feat: plant ์ƒ์„ธ ์กฐํšŒ API

* Docs: update PR template (add checklist)

* Feat: plant ์ƒ์„ธ ์กฐํšŒ service ๋กœ์ง unit test

* Feat: plant ์ƒ์„ธ ์กฐํšŒ controller unit test

* Fix: plants service ๋กœ์ง time mocking

* Feat: env test ํ™˜๊ฒฝ ์„ค์ •

* Feat: e2e test ๊ฒฉ๋ฆฌ๋œ docker ํ™˜๊ฒฝ ๊ตฌ์ถ•

* Feat: plants e2e test

* Feat: ์‹๋ฌผ ์นด๋“œ ์ˆ˜์ • api (#39)

* Feat: ์‹๋ฌผ ์นด๋“œ ์ˆ˜์ • api

* Feat: ์‹๋ฌผ ์นด๋“œ ์ˆ˜์ • api ์ƒ์ˆ˜ ํŒŒ์ผ

* Feat: global exception ์— prisma ์—๋Ÿฌ ์ฒ˜๋ฆฌ ์ถ”๊ฐ€

* Feat: ์‹๋ฌผ ์นด๋“œ ์ˆ˜์ • ํ…Œ์ŠคํŠธ ์ฝ”๋“œ

* Feat: ๋ฉ”์ธ ์‹๋ฌผ ๋ฆฌ์ŠคํŠธ ์กฐํšŒ API (#40)

* Feat: ๋ฉ”์ธ ์‹๋ฌผ ๋ฆฌ์ŠคํŠธ ์กฐํšŒ ์‘๋‹ถ๊ฐ’ ์„ธํŒ…

* Update issue templates

* Feat: ๋ฉ”์ธ ํ™”๋ฉด ๋žœ๋ค description ํ•จ์ˆ˜ ์ถ”๊ฐ€

* Chore: Gauge๋กœ ํ†ต์ผ

* Feat: ๋ฉ”์ธ ์‹๋ฌผ ๋ฆฌ์ŠคํŠธ ์ „์ฒด ์กฐํšŒ API

* Chore: getUserPlants๋กœ ํ•จ์ˆ˜ ์ด๋ฆ„ ๋ณ€๊ฒฝ

* Chore: class ๋Œ€๋ฌธ์ž๋กœ ๋ณ€๊ฒฝ

* Chore: ํ”„๋ฆฌํ‹ฐ์–ด ์ ์šฉ

---------

Co-authored-by: ์žฅ์„œํ˜„ <jangseohyun@jangseohyeon-ui-MacBookAir.local>

---------

Co-authored-by: Chae Jeong Ah <jokj624@gmail.com>
Co-authored-by: ์žฅ์„œํ˜„ <jangseohyun@jangseohyeon-ui-MacBookAir.local>
  • Loading branch information
3 people committed Dec 17, 2023
1 parent 98856f9 commit 480c4ff
Show file tree
Hide file tree
Showing 27 changed files with 1,252 additions and 96 deletions.
18 changes: 13 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
## ๐Ÿ“š PR ์š”์•ฝ / Linked Issue
ํ•ด๋‹น PR์—์„œ ์ž‘์—…ํ•œ ๋‚ด์šฉ์„ ํ•œ ์ค„๋กœ ์š”์•ฝํ•ด์ฃผ์„ธ์š”.

ํ•ด๋‹น PR์—์„œ ์ž‘์—…ํ•œ ๋‚ด์šฉ์„ ํ•œ ์ค„๋กœ ์š”์•ฝํ•ด์ฃผ์„ธ์š”.
close #{no}

## ๐Ÿ’ก ๋ณ€๊ฒฝ ์‚ฌํ•ญ

๋””ํ…Œ์ผํ•œ ์ž‘์—… ๋‚ด์—ญ์„ ์ ์–ด์ฃผ์„ธ์š”.
์ฃผ์˜ํ•  ์‚ฌํ•ญ์ด ์žˆ๋‹ค๋ฉด ์ ์–ด์ฃผ์„ธ์š”.
๋ณ€๊ฒฝ์‚ฌํ•ญ (๋ชจ๋“ˆ ์„ค์น˜ ๋“ฑ)์ด ์žˆ๋‹ค๋ฉด ์ ์–ด์ฃผ์„ธ์š”.

## โœ… PR check list
- [ ] ์ปค๋ฐ‹ ์ปจ๋ฒค์…˜, ์ œ๋ชฉ ๋“ฑ์„ ํ™•์ธํ–ˆ๋‚˜์š”?
- [ ] ์•Œ๋งž์€ ๋ผ๋ฒจ์„ ๋‹ฌ์•˜๋‚˜์š”?
- [ ] ์…€ํ”„ ์ฝ”๋“œ๋ฆฌ๋ทฐ๋ฅผ ์ž‘์„ฑํ–ˆ๋‚˜์š”?
## ๐Ÿ“– Swagger

API Swagger ๋ฅผ ์ถ”๊ฐ€ํ–ˆ๋‹ค๋ฉด ์บก์ณํ•ด์ฃผ์„ธ์š”.

## โœ… PR check list

- [ ] ํ…Œ์ŠคํŠธ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ๋‚˜์š”? (unit/e2e)
- [ ] ์ปค๋ฐ‹ ์ปจ๋ฒค์…˜, ์ œ๋ชฉ ๋“ฑ์„ ํ™•์ธํ–ˆ๋‚˜์š”?
- [ ] ์•Œ๋งž์€ ๋ผ๋ฒจ์„ ๋‹ฌ์•˜๋‚˜์š”?
- [ ] ์…€ํ”„ ์ฝ”๋“œ๋ฆฌ๋ทฐ๋ฅผ ์ž‘์„ฑํ–ˆ๋‚˜์š”?
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ lerna-debug.log*

# env
.env
.env.test

# OS
.DS_Store
Expand Down
20 changes: 20 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Set the version of docker compose to use
version: '3.9'

# The containers that compose the project
services:
db:
image: mysql:8.0
restart: always
container_name: e2e-test-prisma
ports:
- '3306:3306'
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
volumes:
- /var/lib/mysql
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
"test:e2e": "yarn docker:up && sleep 6.5 && yarn migrate:test && yarn seed:test && dotenv -e .env.test -- jest --config ./test/jest-e2e.json && yarn docker:down",
"migrate:test": "dotenv -e .env.test -- npx prisma migrate deploy",
"seed:test": "dotenv -e .env.test -- npx prisma db seed",
"docker:up": "docker-compose -f docker-compose.test.yml up -d",
"docker:down": "docker-compose -f docker-compose.test.yml down -v"
},
"prisma": {
"seed": "cross-env NODE_ENV=test ts-node prisma/seed.ts"
},
"dependencies": {
"@nestjs/axios": "^2.0.0",
Expand All @@ -39,6 +46,7 @@
"class-validator": "^0.14.0",
"dayjs": "^1.11.9",
"dotenv": "^16.0.3",
"dotenv-cli": "^7.2.1",
"jest-mock-extended": "^3.0.4",
"nanoid": "3.3.4",
"passport": "^0.6.0",
Expand All @@ -58,6 +66,7 @@
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"cross-env": "^7.0.3",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
Expand Down
274 changes: 274 additions & 0 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
import { PrismaClient } from '@prisma/client';
import * as dayjs from 'dayjs';
import * as utc from 'dayjs/plugin/utc';
import * as timezone from 'dayjs/plugin/timezone';

dayjs.extend(utc);
dayjs.extend(timezone);

const prisma = new PrismaClient();

async function main() {
const user = await prisma.user.create({
data: {
id: 1,
email: 'ddd',
createdAt: dayjs('2023-07-22 08:15:37.225Z').toDate(),
fcmToken: 'dd',
nickname: 'ddd',
password: 'dd',
phone: 'ddd',
profileImageURL: 'dd',
refreshToken: 'dd',
socialType: 'kakao',
title: 'dd',
updatedAt: dayjs('2023-07-22 08:15:37.225Z').toDate(),
uuid: 'dd',
appleId: null,
appleRefreshToken: null,
kakaoId: 1,
},
});

const plants = await prisma.plant.createMany({
data: [
{
id: 1,
name: '์˜ค๋ Œ์ง€ ์ž์Šค๋ฏผ',
cycle: 2,
introduction: '๋ถ™์ž„์„ฑ์ด ์ข‹์€\n์•™์ฆ๋งž์€ ์˜ค๋ Œ์ง€ ์ž์Šค๋ฏผ',
meaning: '๋‹น์‹ ์„ ํ–ฅํ•ด',
explanation:
'1~2์ผ์— ํ•œ ๋ฒˆ ๋ฌผ์„ ์ฃผ๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•ด์š”\n๋ฌผ์„ ์ข‹์•„ํ•˜๋Š” ์ž์Šค๋ฏผ์ด ๊ณง ๊ท€์—ฌ์šด ์—ด๋งค๋ฅผ ์„ ๋ฌผํ• ๊ฑฐ์—์š”!',
circleImageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/mindlere-circle.png',
gifURL: 'aaa',
},
{
id: 2,
name: '๋กœ์ฆˆ๋งˆ๋ฆฌ',
cycle: 4,
introduction: '๋‹น์‹ ์˜ ํ•˜๋ฃจ๋ฅผ ์น˜์œ ํ•˜๋Š”\nํ–ฅ๊ธฐ๋กœ์šด ๋กœ์ฆˆ๋งˆ๋ฆฌ',
meaning: '๊ธฐ์–ตํ•ด ์ฃผ์„ธ์š”',
explanation:
'3~4์ผ์— ํ•œ ๋ฒˆ ๋ฌผ์„ ์ฃผ๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•ด์š”\n์ž์ฃผ ์—ฐ๋ฝํ•˜๊ณ  ๋งŽ์€ ์‹œ๊ฐ„์„ ํ•จ๊ป˜ํ•˜๋ฉฐ ์ถ”์–ต์„ ์Œ“์•„๊ฐ€์š”!',
circleImageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/rosemari-circle.png',
gifURL: 'aaa',
},
{
id: 3,
name: '์•„๋ฉ”๋ฆฌ์นธ ๋ธ”๋ฃจ',
cycle: 6,
introduction: '๋งค์ผ๋งค์ผ ๊ฝƒ์ด ํ”ผ๋Š”\nํ‘ธ๋ฅธ ๋น›์˜ ์•„๋ฉ”๋ฆฌ์นธ ๋ธ”๋ฃจ',
meaning: '๋‘ ์‚ฌ๋žŒ์˜ ์ธ์—ฐ',
explanation:
'์ผ์ฃผ์ผ์— ํ•œ ๋ฒˆ ๋ฌผ์„ ์ฃผ๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•ด์š”\n์ข…์ข… ์•ˆ๋ถ€๋ฅผ ๋ฌผ์œผ๋ฉด์„œ ์˜ค์†๋„์† ์ด์•ผ๊ธฐ๋ฅผ ๋‚˜๋ˆ„์–ด์š”!',
circleImageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/americanblue-circle.png',
gifURL: 'aaa',
},
{
id: 4,
name: '๋ฏผ๋“ค๋ ˆ',
cycle: 13,
introduction: '๊ฐ์‚ฌํ•˜๋Š” ๋งˆ์Œ์„ ๊ฐ€์ง„\n๋”ฐ๋œปํ•œ ๋ฏผ๋“ค๋ ˆ',
meaning: '์ธ์—ฐ์—์„œ์˜ ํ–‰๋ณต',
explanation:
'๋ณด๋ฆ„์— ํ•œ ๋ฒˆ ๋ฌผ์„ ์ฃผ๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•ด์š”\n๋‹น์‹ ์˜ ์—ฐ๋ฝ์ด ํ™€์”จ๊ฐ€ ๋˜์–ด ๋‚ ์•„๊ฐ€ ํ–‰๋ณต์œผ๋กœ ํ”ผ์–ด๋‚ ๊ฑฐ์—์š”!',
circleImageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/mindlere-circle.png',
gifURL: 'ใ…ใ…',
},
{
id: 5,
name: '์Šคํˆฌํ‚ค',
cycle: 29,
introduction: '์–ธ์ œ๋‚˜ ๋‹น์‹ ์„ ์ง€์ผœ์ฃผ๋Š”\n๋“ ๋“ ํ•œ ์Šคํˆฌํ‚ค',
meaning: '๋„ˆ๊ทธ๋Ÿฌ์›€',
explanation:
'ํ•œ๋‹ฌ์— ํ•œ ๋ฒˆ ๋ฌผ์„ ์ฃผ๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•ด์š”\n๊ฐ€๋”์”ฉ ์—ฐ๋ฝํ•˜๋”๋ผ๋„ ์˜ค๋ž˜ ๋งŒ๋‚  ์ˆ˜ ์žˆ๊ธธ ๋ฐ”๋ผ์š”!',
circleImageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/stuki-circle.png',
gifURL: 'ใ…ใ…',
},
{
id: 6,
name: '๋‹จ๋ชจํ™˜',
cycle: 90,
introduction: '๋‹น์‹ ์˜ ๋ฐค์„ ์ง€์ผœ์ฃผ๋Š”\n์”ฉ์”ฉํ•œ ๋‹จ๋ชจํ™˜',
meaning: '์‚ฌ๋ž‘๊ณผ ์—ด์ •',
explanation:
'์„ธ ๋‹ฌ์— ํ•œ ๋ฒˆ ๋ฌผ์„ ์ฃผ๋Š” ๊ฒƒ์„ ์ถ”์ฒœํ•ด์š”\n์ž์ฃผ ๋ณด์ง€ ๋ชปํ•ด๋„ ๋ถ„๋ช… ๋‹น์‹ ์˜ ์—ฐ๋ฝ์„ ๊ธฐ๋‹ค๋ฆด๊ฑฐ์—์š”!',
circleImageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/danmohwan-circle.png',
gifURL: 'ใ…ใ…ใ…',
},
],
skipDuplicates: true,
});

const plantLevels = await prisma.plantLevel.createMany({
data: [
{
id: 1,
plantId: 1,
level: 0,
levelName: '์–ด๋ฆฐ ๋‚˜๋ฌด',
description: '๋ฌด๋Ÿญ๋ฌด๋Ÿญ ์ž๋ž„ ์ค€๋น„๋ฅผ ํ•˜๊ณ  ์žˆ์–ด์š”!',
imageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/mindlere-1.png',
},
{
id: 2,
plantId: 1,
level: 1,
levelName: '๊ฐœํ™”',
description: 'ํ•˜์–€ ๊ฝƒ์ด ํ™œ์ง ํ”ผ์–ด๋‚ฌ์–ด์š”!',
imageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/mindlere-2.png',
},
{
id: 3,
plantId: 1,
level: 2,
levelName: '์—ด๋งค',
description: '๊ฝƒ์ด ๋จธ๋ฌผ๋‹ค๊ฐ„ ์ž๋ฆฌ์— ์•™์ฆ๋งž์€ ์—ด๋งค๊ฐ€ ์—ด๋ ธ๋„ค์š”!',
imageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/mindlere-complete.png',
},
{
id: 4,
plantId: 2,
level: 0,
levelName: '์ƒˆ์‹น',
description: '์ƒˆ์‹น์ด ์˜์˜ฅ ์–ผ๊ตด์„ ๋‚ด๋ฐ€์—ˆ์–ด์š”!',
imageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/rosemari-1.png',
},
{
id: 5,
plantId: 2,
level: 1,
levelName: '๊ฝƒ๋ง์šธ',
description: '๊ฝƒ๋ง์šธ์ด ๋ฐฉ์šธ๋ฐฉ์šธ ๋งบํ˜”์–ด์š”!',
imageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/rosemari-2.png',
},
{
id: 6,
plantId: 2,
level: 2,
levelName: '๊ฐœํ™”',
description: '์˜ˆ์œ ๊ฝƒ์ด ํ™œ์ง ํ”ผ์–ด๋‚ฌ์–ด์š”!',
imageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/rosemari-complete.png',
},
{
id: 7,
plantId: 3,
level: 0,
levelName: '์ƒˆ์‹น',
description: '์ƒˆ์‹น์ด ์˜์˜ฅ ์–ผ๊ตด์„ ๋‚ด๋ฐ€์—ˆ์–ด์š”!',
imageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/americanblue-1.png',
},
{
id: 8,
plantId: 3,
level: 1,
levelName: '๊ฝƒ๋ง์šธ',
description: '๊ฝƒ๋ง์šธ์ด ๋ฐฉ์šธ๋ฐฉ์šธ ๋งบํ˜”์–ด์š”!',
imageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/americanblue-2.png',
},
{
id: 9,
plantId: 3,
level: 2,
levelName: '๊ฐœํ™”',
description: '์˜ˆ์œ ๊ฝƒ์ด ํ™œ์ง ํ”ผ์–ด๋‚ฌ์–ด์š”!',
imageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/americanblue-complete.png',
},
{
id: 10,
plantId: 4,
level: 0,
levelName: '์ƒˆ์‹น',
description: '์ƒˆ์‹น์ด ์˜์˜ฅ ์–ผ๊ตด์„ ๋‚ด๋ฐ€์—ˆ์–ด์š”!',
imageURL:
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/mindlere-1.png',
},
],
skipDuplicates: true,
});

const userPlant = await prisma.userPlant.create({
data: {
id: 1,
userId: 1,
nickname: 'test',
instagram: null,
phone: null,
waterCycle: 14,
waterCount: 0,
isNotified: true,
loveGauge: 0,
createdAt: dayjs('2023-07-22 08:16:52.538Z').toDate(),
updatedAt: dayjs('2023-07-22 08:16:52.538Z').toDate(),
waterTime: null,
plantId: 4,
},
});

const water = await prisma.water.createMany({
data: [
{
id: 1,
userPlantId: 1,
review: '๋ฆฌ๋ทฐ1',
wateringDate: dayjs('2023-07-22 08:55:31.799Z').toDate(),
updatedAt: dayjs('2023-07-22 08:55:31.799Z').toDate(),
},
{
id: 3,
userPlantId: 1,
review: '๋ฆฌ๋ทฐ2',
wateringDate: dayjs('2023-07-22 18:16:53Z').toDate(),
updatedAt: dayjs('2023-07-22 09:16:54.635Z').toDate(),
},
],
skipDuplicates: true,
});

const waterKeword = await prisma.waterKeyword.createMany({
data: [
{
id: 1,
waterId: 4,
keyword: 'keyword1',
createdAt: dayjs('2023-07-22 12:20:11.257Z').toDate(),
updatedAt: dayjs('2023-07-22 12:20:11.257Z').toDate(),
},
{
id: 2,
waterId: 4,
keyword: 'keyword2',
createdAt: dayjs('2023-07-22 12:20:11.257Z').toDate(),
updatedAt: dayjs('2023-07-22 12:20:11.257Z').toDate(),
},
],
skipDuplicates: true,
});
}

main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});
2 changes: 1 addition & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { PrismaService } from 'src/prisma.service';
ConfigModule.forRoot({
isGlobal: true,
load: [configuration],
envFilePath: '.env',
envFilePath: process.env.NODE_ENV === 'test' ? '.env.test' : '.env',
}),
AuthModule,
HttpModule,
Expand Down
3 changes: 3 additions & 0 deletions src/common/objects/response-message.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export const RESPONSE_MESSAGE: {
REISSUED_TOKEN_SUCCESS: 'ํ† ํฐ ์žฌ๋ฐœ๊ธ‰ ์„ฑ๊ณต',

// plants
READ_PLANT_DETAIL_SUCCESS: '์‹๋ฌผ ์ƒ์„ธ ์กฐํšŒ ์„ฑ๊ณต',
UPDATE_PLANT_DETAIL_SUCCESS: '์‹๋ฌผ ์นด๋“œ ์—…๋ฐ์ดํŠธ ์„ฑ๊ณต',
READ_PLANT_INFORMATION_SUCCESS: '์‹๋ฌผ ๋‹จ๊ณ„ ์กฐํšŒ ์„ฑ๊ณต',
READ_PLANT_WATER_LOG_SUCCESS: '์‹๋ฌผ ๋ฌผ์ฃผ๊ธฐ ๊ธฐ๋ก ์กฐํšŒ ์„ฑ๊ณต',
READ_PLANTS_SUCCESS: '๋ฉ”์ธ ์‹๋ฌผ ๋ฆฌ์ŠคํŠธ ์กฐํšŒ ์„ฑ๊ณต',
};
Loading

0 comments on commit 480c4ff

Please sign in to comment.