codestates / codestates/Bobpago
[πDev Log] λ°μ±ν / 2021.09.24
- Dominant language
- TypeScript
- Stars
- 5
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
### μ€λμ μ΄λ»κ² νλ‘μ νΈμ κΈ°μ¬νλμ?
- λ μνΌ μμ± api μμ±
- λ μνΌ μ΄λ―Έμ§ S3 μ
λ‘λ ꡬν
### μ€λμ νλ‘μ νΈμμ νλ μ μ 무μμΈκ°μ?
- λ μνΌ μμ± μμ² bodyμ μ¬μ§κ³Ό λ μνΌ κ΄λ ¨ μ 보λ₯Ό νλ²μ λ°μμ€λ €κ³ νλλ°, form-dataμ application/JSON λ°μ΄ν° νμμ κ°μ΄ λ°μμ€λκ² μκ°λ³΄λ€ κΉλ€λ‘μμ, μμ²μ λκ°λ‘ λλ΄λ€.
1. μ¬μ§μ μ μΈν λλ¨Έμ§ μ 보μλν λ μνΌ μμ±
2. μ¬μ§μ S3μ μ
λ‘λνλ μμ²
- μ΄λ―Έμ§ url μ 보λ₯Ό μ μ₯ν΄μ£Όλ μμ μ μκ°ν΄λ΄λκ² λ무 μ΄λ €μ λ€.
1. recipeImage ν
μ΄λΈ(λ μνΌ idκΈ°μ€μΌλ‘ κ°κ°μ μ¬μ§κ³Ό μ€λͺ
μ λ΄κ³ μλ ν
μ΄λΈ)μ description(μ¬μ§ 1μ₯μ λν μ€λͺ
)μ λ¨Όμ ν
μ΄λΈ μμ± ν λ°μ΄ν° μ½μ
νλ€.
2. S3 μ¬μ§ μ
λ‘λλ₯Ό μννκ³ λ νμ μμ±λ urlμ recipeImage ν
μ΄λΈμ μ κ·Όνμ¬ μ μ₯νλ€.
```ts
// recipes.service.ts
const newRecipe = await this.recipeRepository.create({
userId: user.id,
title,
amount,
level,
estTime,
});
const recipe = await this.recipeRepository.save(newRecipe);
// μ μ₯μ΄ λλκ³ λ νμ, μμ±λ λ μνΌ idλ₯Ό μ΄μ©νμ¬ recipeIngredient ν
μ΄λΈμ μμ±
await this.createRecipeIngredientId(ingredientId, recipe);
//μμ±λ λ μνΌ idλ₯Ό μ΄μ©νμ¬ recipeImages ν
μ΄λΈμ desc μ μ₯
await this.createRecipeDesc(description, recipe);
return {
data: { recipe },
statusCode: 201,
message: 'λ μνΌ μμ± μλ£',
};
```
### λ΄μΌμ νλ‘μ νΈμ κΈ°μ¬νκΈ° μν΄ λ¬΄μμ ν΄μΌ νλμ?
- S3 μ΄λ―Έμ§ μ
λ‘λ κ²½λ‘ κ΅¬λΆ (λ μνΌ, λκΈ, μ μ νλ‘ν)
- λ μνΌ μμ λ° μμ
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.