Juadah is a bakery that utilizes the web as a platform for purchasing its products. This repository contains the backend for Juadah, developed using TypeScript, Express, MySQL, and Zod to ensure robust API validation and functionality.
if you have any idea, or found some 🐛, please create new issue and we'll do some yapping there
- Technologies Used
- Getting Started
- Running the Application
- Testing
- Postman Collection
- Contribution Guidelines
- License
- TypeScript: For type-safe development.
- Express: As the web framework.
- MySQL: For the database.
- Zod: For data validation and parsing.
- Multer: To handle upload product images process
- Jest: To create unit test
-
Clone the repository:
git clone https://github.com/yourusername/juadah-backend.git cd juadah-backend
-
Install dependencies: I'm using Node v20
npm install
-
Set up environment variables: You can copy the
.env.example
as.env
file and configure it based on your machine environment: -
Run database migrations: This part is missing, I need your help We actually need to make the migrations simpler, but for now im just doing it manually by copy and paste the SQL command that you can found in
db/init.sql
file -
Start the application:
npm run dev
To run the app locally, use the following command:
npm run dev
This will start the Express server and connect to the MySQL database. Ensure you have your .env
file correctly configured.
Unit tests are required for each service. Tests should pass before merging any feature branch into master
or dev
. You can run the test suite with:
npm run test
Make sure that all tests pass when making any pull requests. Any pull request with tests that aren't passed will be rejected automatically
- For each service or feature you implement, write unit tests to cover all functionality.
- Ensure tests are created with complete coverage of edge cases.
Contributors are expected to create new Postman requests for each new endpoint, and ensure that they can run automatically.
- Update the existing Postman collection or create a new one for new API routes.
- Configure the environment settings for Postman and automate updating the environment variables when needed.
- Provide scripts in Postman for handling environment updates when running tests.
- Feat
Used when introducing new functionality or features to the codebase. This type of commit adds something new that wasn't there before
Examples:
- Adding a new API endpoint.
- Implementing a new feature, such as user authentication.
- Adding a new page or functionality to a web app.
- Fix
Used when addressing and resolving a bug or an issue in the code. This type of commit usually deals with a bug reported by users or discovered through testing.
Examples:
- Fixing a broken API endpoint.
- Correcting a typo that causes a bug.
- Resolving an issue where a feature is not working as expected.
- Chore
Used for tasks that don't change the functionality of the codebase or application. These are maintenance tasks or small updates that are not directly related to the product's features or bug fixes.
Examples:
- Updating documentation, like the README.
- Updating dependencies or configuration files.
- Refactoring code without changing its behavior.
- Setting up tools for linting, formatting, or testing.
We welcome contributions! Here's how you can help:
-
Fork the repository and create a new branch: If you want to develop new feature, you can 👇:
git checkout -b feat/<your-feature> git checkout -b feat/add-user-authentication git checkout -b feat/add-order-history-feature
If you have some 🐛fix:
git checkout -b fix/<your-fix> # example git checkout -b fix/checkout-process-error git checkout -b fix/user-login-bug
Or for some chore:
git checkout -b chore/update-readme git checkout -b chore/dependency-updates
-
Make your changes, ensuring the following:
- Write unit tests for any new service.
- All tests must pass before pushing your branch.
- Ensure that all new or updated endpoints are added to the Postman collection.
-
Commit your changes:
- We use Husky and lint-staged to automatically lint and format the code before each commit. This process ensures that the codebase remains consistent and clean.
- If there are any linting or formatting errors, the commit will be blocked. You can fix the issues by running:
npm run fix-lint
- Or if the command doesn't work, that mean you have to resolve that lint or formatting error manually
- Once all issues are resolved, you can commit your changes.
-
Submit a pull request:
- Once your changes are ready, submit a pull request to the
dev
ormaster
branch. - Make sure all tests and lint checks pass.
- Once your changes are ready, submit a pull request to the
We follow a commit message convention to maintain clarity in the project's history. The commit types include:
feat
: For new features.fix
: For bug fixes.chore
: For minor changes like updating dependencies or configuration files.
Let's start hacking 💻