Skip to content

jeffeloy/qrcode-generator-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QR Code Generator

NodeJS Typescript Fastify Zod qrcode Docker AWS SDK

A NodeJs application that generates QR codes and upload them in AWS S3. This project demonstrates the integration of qrcode library for QR code generation and AWS S3 for storage.

Table of Contents

How to Use

This section provides comprehensive instructions for setting up and running the QR Code Generator application.

Prerequisites

  • Node 22+
  • NPM
  • Docker
  • AWS Account with S3 access
  • AWS CLI configured with appropriate credentials

Environment Variables

Create a .env file in the project root with the following variables:

AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=your_region
AWS_BUCKET_NAME=your_bucket_name

Running the Application

Local Development

  1. Create the .env file as described above
  2. Install dependencies:
    npm install
  3. Run the application:
    npm run dev

Docker Deployment

  1. Build the Docker image:
    docker build -t qrcode-generator:X.X . 

Remember to replace the version and image name if you want

  1. Run the container:
    docker run --env-file .env -p 3333:3333 qrcode-generator:X.X 

Remember to replace the .env file path to the path of your environment file that you created.

AWS S3 Configuration

  1. Create an S3 bucket in your AWS account
  2. Update the AWS_BUCKET_NAME in your .env file or Docker run command
  3. Ensure your AWS credentials have appropriate permissions to access the S3 bucket

Application Flow

Note: This diagram was built on Mermaid Online Editor.

API Endpoints

POST /qrcode

Generate a QR code from the provided text and store it in AWS S3. The QR code will be generated as a PNG image with dimensions of 200x200 pixels.

Parameters

Name Required Type Description
text required string The text content to be encoded in the QR code. This can be any string value that you want to convert into a QR code.

Response

{
    "url": "https://your-bucket.s3.your-region.amazonaws.com/random-uuid"
}

Error Response

If an error occurs during QR code generation or S3 upload, the API will return a 500 Internal Server Error.

Example Usage

curl -X POST http://localhost:8080/qrcode \
     -H "Content-Type: application/json" \
     -d '{"text": "https://example.com"}'

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

API Rest to generate QRCode

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published