This is a simple QR code generator made with Node.js and Express.
- Generate QR codes with customizable options:
-
- URL to encode
-
- Image format (PNG, JPEG, WebP)
-
- Size
-
- Error correction level
-
- Dark and light colors
-
- Logo overlay with customizable size ratio
- Cache QR codes for improved performance
- Clear cache manually through API endpoint
http://localhost:8080/api/generate?url=https://github.com/AugustoLL/Qr-Code-Generator-Backend&format=png&size=500&errorCorrectionLevel=Hhttp://localhost:8080/api/generate?url=https://youtube.com&format=png&size=500&errorCorrectionLevel=H&darkColor=%23FF0000&lightColor=%23000000&logoUrl=https://clipart-library.com/images_k/youtube-transparent-png/youtube-transparent-png-15.pnghttp://localhost:8080/api/generate?url=https://www.linkedin.com/in/augusto-lombino-218bba18b&format=png&size=500&errorCorrectionLevel=H&darkColor=%231686B0&lightColor=%23FFFFFF&logoUrl=https://sydneysocialmediamanagers.com.au/wp-content/uploads/2017/03/Linkedin-logo.png&logoSizeRatio=0.2-
Clone the repository:
git clone https://github.com/AugustoLL/Qr-Code-Generator-Backend.git cd qr-code-generator -
Install dependencies:
npm install
-
Start the server:
npm start
The server will start on http://localhost:8080 by default.
This project uses the following environment variables for configuration:
PORT: The port on which the server runs (default: 8080).CACHE_EXPIRATION_TIME: Cache expiration time in seconds (default: 3600).MAX_CACHE_SIZE: Maximum cache size (default: 100).
You can define these variables in a .env file.
PORT=8080
CACHE_EXPIRATION_TIME=3600
MAX_CACHE_SIZE=100
GET /api/generateurl: URL to encode in the QR code (required)format: Image format (png, jpeg, webp; default: png)size: Size of the QR code image (default: 200)errorCorrectionLevel: Error correction level (L, M, Q, H; default: M)darkColor: Dark color of the QR code in hex format (default: #000000)lightColor: Light color of the QR code in hex format (default: #FFFFFF)logoUrl: URL of the logo image to overlay on the QR code (optional)logoSizeRatio: Size ratio of the logo relative to the QR code (default: 0.2)
http://localhost:8080/api/generate?url=https://example.com&format=png&size=300&errorCorrectionLevel=M&darkColor=%230000FF&lightColor=%23FFFF00GET /api/clear-cacheClears the cached QR codes stored for improved performance.
To generate a QR code, open your browser and navigate to:
http://localhost:8080/api/generate?url=YOUR_URL&format=png&size=200
Replace YOUR_URL with the URL you want to encode.
docker build -t qr-code-generator-backend .docker run --env-file .env -p 8080:8080 qr-code-generator-backendAlternatively, you can pass individual environment variables directly:
docker run -e NODE_ENV=production -e API_KEY=your_api_key_here -p 8080:8080 qr-code-generatorTo use Docker Compose, run the following command:
docker-compose up- Change the style of the shapes of the QR Code
- Allow QR Codes for
-
- contact:
-
-
- name: name, last name
-
-
-
- contact: mobile number, phone number, fax, email
-
-
-
- company: company, job
-
-
-
- street
-
-
-
- city: name, zip
-
-
-
- state
-
-
-
- country
-
-
-
- website
-
-
- wifi: network name, password, encryption (none, wpa/wpa2, wep)
-
- emails: address, subject, message
-
- sms: number, message
- Allow for gradients when setting the colors
- Add Dynamic QR Codes (codes that can be updated without changing the printed code)


