qrcode-generator-using-link
v1.0.0
Published
Qr code generating using the link
Downloads
3
Maintainers
Readme
QR Code Generator API
This is a simple Express.js application that generates and serves QR codes based on provided URLs and parameters. It includes health checks and validates URLs against a list of allowed domains.
Table of Contents
Installation
Clone the repository:
git clone https://github.com/your-username/your-repo.git cd your-repo
Install dependencies:
npm install
Create a
.env
file and set your environment variables:PORT=3000
Start the application:
npm start
Usage
After starting the application, it will be running on the port specified in your .env
file or default to port 3000. You can access the health check endpoint and the QR code generation endpoint as described below.
API Endpoints
Health Check
- Endpoint:
/health
- Method: GET
- Description: Returns a status message to indicate the server is running.
Response
- Status Code: 200 OK
- Body:
health page
Generate QR Code
- Endpoint:
/qrcode/download
- Method: GET
- Description: Generates a QR code based on the provided query parameters and returns the image.
Query Parameters
chs
(required): Size of the QR code in the formatWIDTHxHEIGHT
(e.g.,200x200
).cht
(required): Type of chart, should beqr
.chl
(required): URL-encoded data for the QR code.fileType
(optional): File type of the QR code image (png
orsvg
). Defaults topng
.
Response
- Status Code: 200 OK
- Headers:
Content-Type
:image/png
orimage/svg+xml
Content-Disposition
:attachment; filename="qr-code.png"
(or.svg
)
- Body: Binary image data.
Example Request
curl "http://localhost:3000/qrcode/download?chs=200x200&cht=qr&chl=https%3A%2F%2Fexample.com&fileType=png"