Skip to content

A simple HTTP proxy for MySQL, designed for serverless environments like Cloudflare Workers.

Notifications You must be signed in to change notification settings

ntaheij/mysql-http-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mysql-http-proxy

A simple HTTP proxy for MySQL, designed for serverless environments like Cloudflare Workers.

😔 The Problem

Serverless environments such as AWS Lambda are not suited for database connections. Traditional databases such as MySQL can be easily slowed to a crawl by handling too many connections; plus, as of March 2022, Cloudflare Workers don't even support TCP which relation databases require!

🎉 The Solution

Enter mysql-http-proxy. It sits on a server and acts as a super-simple database proxy, exposing an HTTP endpoint and ensuring only one connection is ever open to your database at once.

🤔 How to Use

Spin up a server anywhere you desire. Clone the repo, rename the .env.template file to .env and modify your MySQL endpoint. Run npm run start and away you go! 🚀

Run a query to http://endpoint:3001/query with a body of:

{
  "query": "YOUR_REGULAR_SQL_QUERY_HERE"
}

Your response will be either:

{
  "error": "Descriptive error message."
}

or the response to your SQL query in JSON.

About

A simple HTTP proxy for MySQL, designed for serverless environments like Cloudflare Workers.

Resources

Stars

Watchers

Forks