StarShop's backend supports the innovative features of the platform, providing a robust and scalable API layer that integrates blockchain technology, database management, and service logic for a seamless marketplace experience.
This document outlines the rules and guidelines for contributing to the backend of the StarShop project. By following these rules, contributors ensure consistent development practices and smooth collaboration across the team.
The backend project follows a clear and modular folder structure:
Folder/File | Description |
---|---|
src/config |
Configuration files (e.g., database settings). |
src/entities |
Entity models for database interactions. |
src/services |
Business logic and services. |
src/utils |
Helper utilities and common functions. |
src/tests |
Unit and integration tests. |
src/index.ts |
Application entry point. |
- Language: TypeScript is the default language.
- Linting: Use ESLint for code quality.
- Formatting: Use Prettier for consistent formatting.
- Naming Conventions:
- Use camelCase for variables and functions.
- Use PascalCase for classes, interfaces, and types.
- Use UPPER_SNAKE_CASE for constants.
To ensure adherence, run the following commands before committing:
npm run lint
- Check for linting issues.npm run format
- Apply code formatting.
- Create a new branch for each feature or bugfix.
- Ensure the branch is up-to-date with the main branch.
- Add appropriate tests for your changes.
- Submit a detailed pull request with:
- A descriptive title.
- Clear summary of changes.
- Await at least one code review approval before merging.
Branch | Description |
---|---|
main |
Production-ready code. |
develop |
Staging branch for upcoming releases. |
feature/<feature-name> |
New features under development. |
bugfix/<bug-name> |
Bug fixes. |
Use the following format for commits:
[Type] [Scope]: [Short Description]
Examples:
feat: Add authentication middleware.
fix: Resolve database connection issue.
-
Clone the repository:
npm clone https://github.com/StarShopCr/StarShop-Backend.git
-
Navigate to the directory:
cd StarShop-Backend
-
Install dependencies:
npm install
-
Copy and configure environment variables:
cp .env.example .env
-
Start the development server:
npm run dev
We use Jest for unit and integration testing. Ensure all new features include test coverage.
npm run test
- Run all tests.npm run test:watch
- Run tests in watch mode during development.
Unit Test Example:
Tests are located under the src/tests
folder.
Each service, utility, or feature should have a corresponding *.spec.ts
file.
We welcome contributions to StarShop! Follow these guidelines and refer to our Contributor's Guide to get started.
- Always update documentation when making changes.
- Ensure your code passes all tests before submitting a pull request.
- Stick to the project coding standards for better collaboration.