Skip to main content

Common utilities for EriPotter microservices

Project description

EriPotter Common

EriPotter 마이크로서비스를 위한 공통 유틸리티 패키지입니다.

기능

  • 환경변수 기반 설정 관리
  • 비동기 데이터베이스 연결 및 세션 관리
  • FastAPI 확장 기능 (CORS, 헬스 체크 등)
  • 보안 유틸리티 (비밀번호 해시화)
  • 구조화된 로깅

설치

pip install eripotter-common

마이그레이션 가이드

기존 common/ 폴더에서 PyPI 패키지로 마이그레이션하는 방법:

  1. 기존 common/ 폴더 제거
rm -rf common/  # Linux/Mac
rd /s /q common  # Windows
  1. PyPI 패키지 설치
pip install eripotter-common
  1. import 문 수정
# 이전
from common.config import settings
from common.db import get_db_engine
from common.security import hash_password

# 이후
from app import settings, db, hash_password

# 데이터베이스 사용
engine = await db.initialize()
async with db.session() as session:
    # 데이터베이스 작업
    pass

사용 예시

FastAPI 애플리케이션 생성

from app import create_app, settings, setup_logging, get_session, db, Base

# 로깅 설정
setup_logging()

# FastAPI 앱 생성
app = create_app(
    title="My Service",
    description="My Microservice"
)

# 모델 정의
class User(Base):
    __tablename__ = "users"
    # ... 모델 정의

# 라우터
@app.get("/users")
async def get_users(session = Depends(get_session)):
    users = await session.query(User).all()
    return users

환경변수 설정 (.env)

# 필수 설정
DATABASE_URL=postgresql+asyncpg://user:pass@localhost/db
SERVICE_NAME=my-service

# 선택적 설정
SQL_ECHO=true
LOG_LEVEL=INFO
JSON_LOGS=true
PORT=8000

개발 환경 설정

  1. 저장소 클론
git clone https://github.com/eripotter/eripotter-common.git
cd eripotter-common
  1. 가상환경 생성 및 활성화
python -m venv venv
source venv/bin/activate  # Linux/Mac
venv\Scripts\activate     # Windows
  1. 개발 의존성 설치
pip install -e ".[test]"
  1. 테스트 실행
pytest

라이선스

MIT License - 자세한 내용은 LICENSE 파일을 참조하세요.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eripotter_common-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eripotter_common-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file eripotter_common-0.1.0.tar.gz.

File metadata

  • Download URL: eripotter_common-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for eripotter_common-0.1.0.tar.gz
Algorithm Hash digest
SHA256 599eb65e362b25c18353aa7f26976f0daea8d1efee12c1f713e37779f25077f3
MD5 59751e8163bf0e0bb3a4bc9758942d68
BLAKE2b-256 1f276e43f92d875ae6337afc1c79ca3b0d0ad0367ea65cac824dd6f82688b928

See more details on using hashes here.

Provenance

The following attestation bundles were made for eripotter_common-0.1.0.tar.gz:

Publisher: publish-pypi.yml on yeseung-2/eripotter-common

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eripotter_common-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for eripotter_common-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc18a62fde485e1d836ea8ac480eb72b0cdced76a3c553a8d9ffcbd98e8b427d
MD5 c7b95f3a403dd38c18c2d9cbf2fcbce3
BLAKE2b-256 02c8043190210d7791e2b0e87b97725d9c32f384952ede5e46d9d1f1aed4e4df

See more details on using hashes here.

Provenance

The following attestation bundles were made for eripotter_common-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on yeseung-2/eripotter-common

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page