A NestJS-based REST API for the GoodsDesign platform.
This API serves as the backend for the GoodsDesign platform, providing endpoints for managing goods, designs, and related resources. Built with NestJS, it follows modern architectural patterns and best practices.
- GraphQL API endpoints
- Prisma ORM for database operations
- Docker containerization
- TypeScript support
- Automated testing setup
- Node.js (v16 or higher)
- npm or yarn
- Docker and Docker Compose (for containerized development)
- PostgreSQL database
- Clone the repository:
git clone https://github.com/your-username/goodsdesign-api.git
cd goodsdesign-api- Install dependencies:
npm install- Set up environment variables:
cp .env.example .envEdit the .env file with your configuration.
Environment variables format:
# Database Configuration
DATABASE_URL="postgresql://username:password@localhost:5432/database_name?schema=public"
# JWT Configuration
JWT_ACCESS_TOKEN_SECRET="your_access_token_secret"
JWT_ACCESS_TOKEN_EXPIRES_IN="15m"
JWT_REFRESH_TOKEN_SECRET="your_refresh_token_secret"
JWT_REFRESH_TOKEN_EXPIRES_IN="7d"
# Redis Configuration
REDIS_URL="redis://localhost:6379"
REDIS_TTL="604800"
# GHN (Giao Hàng Nhanh) Configuration
GHN_TOKEN="your_ghn_token"
GHN_SHOP_ID="your_shop_id"
GHN_BASE_URL="https://dev-online-gateway.ghn.vn"
# Payment Configuration
PAYMENT_PAYOS_CLIENT_ID="your_payos_client_id"
PAYMENT_PAYOS_API_KEY="your_payos_api_key"
PAYMENT_PAYOS_CHECKSUM_KEY="your_payos_checksum_key"
PAYMENT_PAYOS_CANCEL_URL="https://your-domain.com/payment"
PAYMENT_PAYOS_RETURN_URL="https://your-domain.com/payment"
PAYMENT_VNPAY_RETURN_URL="https://your-domain.com/payment"
PAYMENT_VNPAY_VNP_URL="https://sandbox.vnpayment.vn/paymentv2/vpcpay.html"
PAYMENT_VNPAY_TMN_CODE="your_tmn_code"
PAYMENT_VNPAY_HASH_SECRET="your_hash_secret"
PAYMENT_VNPAY_VERSION="2.1.0"
# Cloudinary Configuration
CLOUDINARY_CLOUD_NAME="your_cloud_name"
CLOUDINARY_API_KEY="your_api_key"
CLOUDINARY_API_SECRET="your_api_secret"
# File Upload Configuration
UPLOAD_MAX_FILE_SIZE=50000000
UPLOAD_MAX_FILES=1
# Email Configuration
RESEND_API_KEY="your_resend_api_key"
# Frontend Configuration
APP_FRONTEND_URL="http://localhost:3000"- Start the development database:
docker-compose up -d- Run database migrations:
npx prisma migrate dev# development
npm run start
# watch mode
npm run start:dev
# production mode
npm run start:prod# unit tests
npm run test
# e2e tests
npm run test:e2e
# test coverage
npm run test:covThe application can be deployed using Docker:
# Using Docker Compose (recommended for development)
docker compose up -d
# Or using individual Docker commands
# Build the image
docker build -t goodsdesign-api .
# Run the container
docker run -p 3000:3000 goodsdesign-apiAPI documentation is available at /api when running the application in development mode.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.