A modern, secure, and self-hostable platform for virtual product delivery. This application allows you to create and manage digital products and provide your customers with a simple and secure way to claim them using their order ID.
- Secure Product Claiming: Customers can claim their virtual products using their unique order ID.
- Admin Dashboard: A comprehensive dashboard for managing products, orders, and application settings.
- Customizable Orders: Create orders with specific products, set expiration dates, and configure one-time use policies.
- Security-First: Includes rate limiting, CSRF protection, and a robust Content Security Policy (CSP) to protect against common web vulnerabilities.
- Dockerized: Comes with a multi-stage
Dockerfileanddocker-compose.ymlfor easy production deployment. - CI/CD Ready: Includes a comprehensive CI/CD workflow for automated testing, security scanning, and Docker image publishing.
- Node.js (v20.x or later)
- npm (v10.x or later)
- Docker and Docker Compose (for production deployment)
-
Clone the repository:
git clone https://github.com/johnyww/self-claim-link-v2.git cd self-claim-link-v2 -
Install dependencies:
npm install
-
Set up environment variables: Copy the
.env.examplefile to a new file named.envand fill in the required values:cp .env.example .env
Be sure to generate a strong
JWT_SECRETand a secureDEFAULT_ADMIN_PASSWORD.
-
Development: To start the development server, run:
npm run dev
The application will be available at
http://localhost:3000. -
Production Build: To build the application for production, run:
npm run build
-
Production Start: To start the production server, run:
npm run start
This project is configured for easy deployment with Docker and Docker Compose.
-
Build and start the services:
docker-compose up --build -d
This will build the application image and start the
app,postgres,redis, andbackupservices in detached mode. -
Accessing the application: The application will be available at
http://localhost:3000. -
Stopping the services:
docker-compose down
-
Unit and Integration Tests (Jest):
npm test -
Test Coverage: To run tests and generate a coverage report:
npm run test:coverage
The report will be available in the
coverage/directory. -
End-to-End Tests (Playwright):
npm run test:e2e
Contributions are welcome! Please read the CONTRIBUTING.md file for guidelines on how to contribute to this project.
This project is licensed under the MIT License - see the LICENSE file for details.
This section provides a complete guide to push your project to GitHub and build/push multi-platform Docker images to DockerHub.
- Git: You must have Git installed on your local machine.
- Docker: You must have Docker installed and running.
- GitHub Account: You need a GitHub account and a new repository created for this project.
- DockerHub Account: You need a DockerHub account.
These commands will initialize a new Git repository, add all files, commit them, and push to your existing GitHub repository.
-
Initialize Git and commit all changes:
git init git add . git commit -m "Initial commit: Project setup and professionalization"
-
Set up the remote repository: Replace
johnyww/self-claim-link-v2.gitwith your actual repository URL.git remote add origin https://github.com/johnyww/self-claim-link-v2.git
-
Push to the
mainbranch:git branch -M main git push -u origin main
These steps will guide you through setting up docker buildx, logging in to DockerHub, and building/pushing your multi-platform Docker image.
-
Log in to DockerHub: Enter your DockerHub username (
johnywy) and password when prompted.docker login
-
Set up
docker buildx: Create and switch to a new builder instance that supports multi-platform builds.docker buildx create --name multi-platform-builder --use docker buildx inspect --bootstrap
-
Build and push the multi-platform image: This command will build the Docker image for both
linux/amd64(standard PCs, cloud servers) andlinux/arm64(Apple Silicon, Raspberry Pi, some cloud instances), and push them to your DockerHub repository.The image will be tagged with
latestand a semantic version tag based onpackage.json(e.g.,0.1.0).docker buildx build \ --platform linux/amd64,linux/arm64 \ -t johnywy/self-claim-link-v2:latest \ -t johnywy/self-claim-link-v2:0.1.0 \ --push \ .
In case something goes wrong, here's how you can roll back your changes.
To revert the last commit you pushed to GitHub, you can use git revert. This will create a new commit that undoes the changes from the previous commit, which is a safe way to roll back.
-
Revert the last commit:
git revert HEAD --no-edit
-
Push the revert commit:
git push origin main
There's no direct "rollback" for a Docker image tag. The strategy is to re-tag a previously known-good image with the latest tag.
-
Pull the specific version you want to roll back to: (Assuming
0.0.9was the last stable version)docker pull johnywy/self-claim-link-v2:0.0.9
-
Re-tag the old version as
latest:docker tag johnywy/self-claim-link-v2:0.0.9 johnywy/self-claim-link-v2:latest
-
Push the
latesttag to DockerHub:docker push johnywy/self-claim-link-v2:latest
This will ensure that anyone pulling the latest tag gets the old, stable version.