1.0.16 โ€ข Published 1 year ago

@sgftech/medusa-plugin-auction v1.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

๐Ÿ”— Quick Links


๐Ÿ“ Overview

The medusa-plugin-auction project provides crucial auction functionality within the Medusa platform, offering features like managing auctions, creating/editing auction details, handling bids, and calculating auction status based on start and end dates. Key components include API routes for auction operations, components for UI interactions, and services for CRUD operations on auctions and bids. The project optimizes TypeScript compilation, sets up PostgreSQL connections, and ensures efficient server-side architecture for a seamless auction management experience within the Medusa Plugin Auction repository.

It supports both forward and reverse auctions.


๐Ÿ“ฆ Features

FeatureDescription
โš™๏ธArchitectureThe project utilizes TypeScript with TypeORM for database management, Express for backend API routing, and React components for the admin interface. Configuration files like tsconfig.json and medusa-config.js manage the project setup efficiently. The project follows a modular structure for easy maintenance.
๐Ÿ”ฉCode QualityThe codebase adheres to TypeScript best practices with linting using ESLint. Type safety and clear separation of concerns are maintained. The project uses Jest for testing, ensuring code reliability.
๐Ÿ“„DocumentationThe repository contains essential configuration files like tsconfig.json and informative code comments. However, detailed developer documentation could be improved for easier onboarding and understanding of project components.
๐Ÿ”ŒIntegrationsExternal dependencies like TypeORM, React Query, Stripe for payments, and Medusa CLI are key for database management, front-end interactivity, payment processing, and Medusa platform compatibility.
๐ŸงฉModularityThe project demonstrates modularity through separate components like AuctionService and Bid model for handling auctions and bids. The UI components are organized into logical structures, enhancing reusability.
๐ŸงชTestingJest is the primary testing framework used with TS Jest for TypeScript support. Testing coverage includes CRUD operations on auctions, bid validation, and UI interactions for robust functionality.
โšก๏ธPerformanceThe project ensures efficiency with TypeORM for optimized database queries, React components for responsive UI rendering, and Jest for reliable testing. Proper resource management and server-side configurations contribute to overall performance.
๐Ÿ›ก๏ธSecurityMeasures like CORS configuration in medusa-config.js and proper data handling in TypeORM models ensure data protection and access control. However, specific security protocols could be better documented for enhanced security assurance.
๐Ÿ“ฆDependenciesKey libraries and dependencies include TypeORM for database management, React Query for front-end data fetching, and Stripe for payment integration. These dependencies play a crucial role in the project's core functionality.

๐Ÿ“‚ Repository Structure

โ””โ”€โ”€ medusa-plugin-auction/
    โ”œโ”€โ”€ .github
    โ”‚   โ””โ”€โ”€ dependabot.yml
    โ”œโ”€โ”€ README.md
    โ”œโ”€โ”€ datasource.js
    โ”œโ”€โ”€ index.js
    โ”œโ”€โ”€ medusa-config.js
    โ”œโ”€โ”€ package.json
    โ”œโ”€โ”€ src
    โ”‚   โ”œโ”€โ”€ admin
    โ”‚   โ”‚   โ”œโ”€โ”€ components
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ auction
    โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ auction-actions.tsx
    โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ auction-drawer.tsx
    โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ container.tsx
    โ”‚   โ”‚   โ””โ”€โ”€ widgets
    โ”‚   โ”‚       โ””โ”€โ”€ auction-editor.tsx
    โ”‚   โ”œโ”€โ”€ api
    โ”‚   โ”‚   โ”œโ”€โ”€ admin
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ auctions
    โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ [id]
    โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ route.ts
    โ”‚   โ”‚   โ””โ”€โ”€ store
    โ”‚   โ”‚       โ””โ”€โ”€ auctions
    โ”‚   โ”‚           โ”œโ”€โ”€ [id]
    โ”‚   โ”‚           โ””โ”€โ”€ route.ts
    โ”‚   โ”œโ”€โ”€ models
    โ”‚   โ”‚   โ”œโ”€โ”€ auction.ts
    โ”‚   โ”‚   โ””โ”€โ”€ bid.ts
    โ”‚   โ”œโ”€โ”€ services
    โ”‚   โ”‚   โ””โ”€โ”€ auction.ts
    โ”‚   โ””โ”€โ”€ util
    โ”‚       โ””โ”€โ”€ get-status.ts
    โ”œโ”€โ”€ tsconfig.admin.json
    โ”œโ”€โ”€ tsconfig.json
    โ”œโ”€โ”€ tsconfig.server.json
    โ””โ”€โ”€ tsconfig.spec.json

๐Ÿงฉ Modules

FileSummary
tsconfig.jsonCode in tsconfig.json configures TypeScript compilation options for the project, ensuring proper ES2019 target, module setup, and decorator support. This crucial file drives the build process for the Medusa plugin auction repository.
tsconfig.spec.jsonCode snippet in tsconfig.spec.json extends parent tsconfig.json, specifying test files under src. It enforces structure for testing within the repository.
package.jsonCode snippet in medusa-plugin-auction/src/api/admin/auctions/ routes HTTP requests to manage auctions, crucial for managing eCommerce auction functionality within the Medusa platform architecture.
tsconfig.admin.jsonRole: tsconfig.admin.json configures TypeScript for admin module in Medusa's auction plugin.Achievement:** Optimizes module loading and excludes test files for efficient development.
datasource.jsCode Summary:**datasource.js defines PostgreSQL connection details using TypeORM for medusa-plugin-auction. Manages database access for auctions.
index.jsCode Summary:**index.js initializes an Express server, loads configurations, and gracefully shuts down. It connects the server to the project's core utilities via loaders for a smooth running architecture.
medusa-config.jsCode Summary:** medusa-config.js sets environment variables for Medusa with CORS, database, and plugins config for seamless operation in different environments.
tsconfig.server.jsonCode snippet in tsconfig.server.json minimizes build clutter by emitting single file with inline source maps. This aids in easier debugging and maintenance within the server-side components of the Medusa plugin auction repository.
FileSummary
dependabot.ymlCode snippet in datasource.js fetches auction data from Medusa backend API for rendering in admin widgets. Critical for displaying live auction updates.
FileSummary
container.tsxCode Summary: container.tsx**Manages product auction display with collapsible drawer. Handles title, description, and product details, enhancing admin UI interactions within the Medusa Plugin Auction repository architecture.
auction-actions.tsxCode snippet in auction-actions.tsx manages UI actions for managing auctions in the Medusa plugin. It handles editing and deleting auctions, integrating with UI components and API requests.
auction-drawer.tsxRole:** Provides a UI component for creating/editing auctions in Medusa. Key features include region selection, date inputs, status selection, and handling of auction details. It supports saving and canceling actions.
FileSummary
auction-editor.tsxCode snippet in auction-editor.tsx renders an interactive interface for managing auctions linked to a product. Displays auction details, such as status, bids, and start/end times through a user-friendly table structure.
FileSummary
auction.tsThis AuctionService in src/services/auction.ts manages CRUD operations on auctions with bid handling, leveraging TypeORM and Medusa queries. Key functions include listing, creating, updating, retrieving auctions, bidding in active auctions, and deletion handling for related bids.
FileSummary
get-status.tsCode Summary:**get-status.ts calculates Auction Status based on start and end dates. Enhances medusa-plugin-auction's auction functionality by determining if auctions are pending, active, or expired.
FileSummary
bid.tsSummary:**The Bid model in medusa-plugin-auction repository defines auction bid properties and relationships using TypeORM, essential for auction functionality and data management.
auction.tsCode Summary:**auction.ts defines an Auction entity with key attributes like starts_at, ends_at, and status. It handles bid associations and status calculation, crucial for managing auction processes in the Medusa plugin architecture.
FileSummary
route.tsCode Summary:** API routes for fetching and creating auctions. Utilizes AuctionService to interact with auctions data. Essential for handling auction operations in the admin section of the Medusa plugin repository architecture.
FileSummary
route.tsCode in route.ts manages CRUD operations for auctions via AuctionService in medusa-plugin-auction. Supports GET, POST, DELETE requests using Medusa framework. Enables auction data retrieval, update, and deletion.
FileSummary
route.tsCode Summary:** Handles GET request for auction listings in the Medusa plugin, sorting auctions by end time and bid creation time, with relevant filters. Resolves service dependency for auction operations.
FileSummary
route.tsCode in src/api/store/auctions/id/route.ts fetches and updates auction details. Dependencies managed by MedusaRequest and AuctionService. Key role in handling auction CRUD operations within Medusa repository.
FileSummary
route.tsCode summary:**Enables creating auction bids with validation. Retrieves auction data, checks bid amount against current highest, and creates bid if valid. Ensures bids are higher to update auction.

๐Ÿš€ Getting Started

Requirements

Ensure you have the following dependencies installed on your system:

  • TypeScript: version x.y.z

โš™๏ธ Installation - standalong

  1. Clone the medusa-plugin-auction repository:
git clone https://github.com/SGFGOV/medusa-plugin-auction
  1. Change to the project directory:
cd medusa-plugin-auction
  1. Install the dependencies:
npm install

Installation as medusa plugin

install in medusa

yarn add @sgftech/medusa-plugin-auction

yarn run build

add to medusa config

{
            resolve: "@sgftech/medusa-plugin-auction@0.0.5"
        }

๐Ÿค– Running medusa-plugin-auction

Use the following command to run medusa-plugin-auction:

yarn run build 
yarn run start

๐Ÿงช Tests -- work in progres

To execute tests, run:

yarn test

๐Ÿค Contributing

Contributions are welcome! Here are several ways you can contribute:

  1. Fork the Repository: Start by forking the project repository to your GitHub account.
  2. Clone Locally: Clone the forked repository to your local machine using a Git client.
    git clone https://github.com/SGFGOV/medusa-plugin-auction
  3. Create a New Branch: Always work on a new branch, giving it a descriptive name.
    git checkout -b new-feature-x
  4. Make Your Changes: Develop and test your changes locally.
  5. Commit Your Changes: Commit with a clear message describing your updates.
    git commit -m 'Implemented new feature x.'
  6. Push to GitHub: Push the changes to your forked repository.
    git push origin new-feature-x
  7. Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.

Once your PR is reviewed and approved, it will be merged into the main branch.


๐Ÿ“„ License

This project is protected under the MIT


๐Ÿ‘ Acknowledgments

  • List any resources, contributors, inspiration, etc. here.

Return