fastify-boilerplate

(β˜… 461)

Fastify 5 application boilerplate based on clean architecture, domain-driven design, CQRS, functional programming, vertical slice architecture for building production-grade applications πŸš€

  • .dependency-cruiser.cjs
  • .dockerignore
  • .editorconfig
  • .env.example
  • .gitattributes
  • .gitignore
  • .nvmrc
  • .releaserc
  • AGENTS.md
  • biome.json
  • CHANGELOG.md
  • CLAUDE.md
  • commitlint.config.cjs
  • cucumber.mjs
  • docker-compose.yml
  • Dockerfile
  • LICENSE
  • package.json
  • pnpm-lock.yaml
  • pnpm-workspace.yaml
  • README.md
  • renovate.json
  • tsconfig.json

# μ„€μΉ˜ κ°€μ΄λ“œ

1. μ½”λ“œ λ‚΄λ €λ°›κΈ°
git clone https://github.com/marcoturi/fastify-boilerplate

κΉƒν—ˆλΈŒμ—μ„œ ν”„λ‘œμ νŠΈ μ½”λ“œ 전체λ₯Ό λ‚΄ μ»΄ν“¨ν„°λ‘œ λ‚΄λ €λ°›μŠ΅λ‹ˆλ‹€.

cd fastify-boilerplate

방금 내렀받은 ν”„λ‘œμ νŠΈ 폴더 μ•ˆμœΌλ‘œ μ΄λ™ν•©λ‹ˆλ‹€.

2. Docker

쉬움 μΆ”μ²œ
사전 μ€€λΉ„λ¬Ό
  • Git GitHubμ—μ„œ ν”„λ‘œμ νŠΈ μ½”λ“œλ₯Ό λ‚΄λ €λ°›μœΌλ €λ©΄ ν•„μš”ν•©λ‹ˆλ‹€.
  • Docker Desktop μ»¨ν…Œμ΄λ„ˆλ₯Ό λΉŒλ“œν•˜κ³  μ‹€ν–‰ν•˜λ €λ©΄ ν•„μš”ν•©λ‹ˆλ‹€. μ„€μΉ˜ ν›„ μ‹€ν–‰ν•΄μ„œ λ°±κ·ΈλΌμš΄λ“œμ— μΌœλ‘μ„Έμš”.
docker compose up postgres -d # via Docker Compose

μ •μ˜λœ λͺ¨λ“  μ»¨ν…Œμ΄λ„ˆ(μ„œλ²„, DB λ“±)λ₯Ό ν•œ λ²ˆμ— λΉŒλ“œν•˜κ³  λ°±κ·ΈλΌμš΄λ“œμ—μ„œ μ‹€ν–‰ν•©λ‹ˆλ‹€.

docker compose up # builds the app image and starts all services

μ •μ˜λœ λͺ¨λ“  μ»¨ν…Œμ΄λ„ˆ(μ„œλ²„, DB λ“±)λ₯Ό ν•œ λ²ˆμ— λΉŒλ“œν•˜κ³  λ°±κ·ΈλΌμš΄λ“œμ—μ„œ μ‹€ν–‰ν•©λ‹ˆλ‹€.

docker build -t fastify-boilerplate .

Dockerfile을 기반으둜 μ‹€ν–‰ κ°€λŠ₯ν•œ 이미지λ₯Ό λΉŒλ“œν•©λ‹ˆλ‹€.

docker run -p 3000:3000 --env-file .env -e HOST=0.0.0.0 fastify-boilerplate

λΉŒλ“œλœ 이미지λ₯Ό μ‹€μ œ μ»¨ν…Œμ΄λ„ˆλ‘œ μ‹€ν–‰ν•©λ‹ˆλ‹€.

βœ… 터미널에 docker compose ps λ₯Ό μž…λ ₯ν•΄ μ»¨ν…Œμ΄λ„ˆλ“€μ΄ Up μƒνƒœμΈμ§€ ν™•μΈν•˜μ„Έμš”. README에 포트 λ²ˆν˜Έκ°€ μ ν˜€μžˆλ‹€λ©΄ λΈŒλΌμš°μ €μ—μ„œ http://localhost:포트번호 둜 μ ‘μ†ν•΄λ³΄μ„Έμš”.

이 레포의 README에 적힌 μ‹€μ œ λͺ…λ Ήμ–΄λ₯Ό κ·ΈλŒ€λ‘œ κ°€μ Έμ™”μŠ΅λ‹ˆλ‹€.

3. Node.js

쉬움
사전 μ€€λΉ„λ¬Ό
  • Git GitHubμ—μ„œ ν”„λ‘œμ νŠΈ μ½”λ“œλ₯Ό λ‚΄λ €λ°›μœΌλ €λ©΄ ν•„μš”ν•©λ‹ˆλ‹€.
  • Node.js npm λͺ…λ Ήμ–΄λ₯Ό μ“°λ €λ©΄ Node.jsκ°€ μ„€μΉ˜λ˜μ–΄ μžˆμ–΄μ•Ό ν•©λ‹ˆλ‹€. LTS(μž₯기지원) 버전을 μΆ”μ²œν•©λ‹ˆλ‹€.
pnpm install

package.json에 λͺ…μ‹œλœ λΌμ΄λΈŒλŸ¬λ¦¬λ“€μ„ λ‚΄λ €λ°›μ•„ μ„€μΉ˜ν•©λ‹ˆλ‹€.

pnpm create:env # copies .env.example β†’ .env

이 λͺ…λ Ήμ–΄λ₯Ό 터미널에 κ·ΈλŒ€λ‘œ μž…λ ₯ν•΄ μ‹€ν–‰ν•˜μ„Έμš”.

pnpm db:migrate

이 λͺ…λ Ήμ–΄λ₯Ό 터미널에 κ·ΈλŒ€λ‘œ μž…λ ₯ν•΄ μ‹€ν–‰ν•˜μ„Έμš”.

pnpm start

개발/μ‹€ν–‰ μ„œλ²„λ₯Ό μΌ­λ‹ˆλ‹€.

pnpm create:env # create .env from .env.example (if not done already)

이 λͺ…λ Ήμ–΄λ₯Ό 터미널에 κ·ΈλŒ€λ‘œ μž…λ ₯ν•΄ μ‹€ν–‰ν•˜μ„Έμš”.

βœ… λͺ…λ Ήμ–΄ μ‹€ν–‰ ν›„ 터미널에 λ‚˜νƒ€λ‚˜λŠ” μ£Όμ†Œ(보톡 http://localhost:3000 ν˜•νƒœ)λ₯Ό λΈŒλΌμš°μ €μ—μ„œ μ—΄μ–΄λ³΄μ„Έμš”.

이 레포의 README에 적힌 μ‹€μ œ λͺ…λ Ήμ–΄λ₯Ό κ·ΈλŒ€λ‘œ κ°€μ Έμ™”μŠ΅λ‹ˆλ‹€.

// repository documentation