New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cf-sql-gateway-prototype

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cf-sql-gateway-prototype

Example Cloudflare worker that interfaces with a SQL database over HTTPS

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

SQL Gateway Worker Prototype

This worker will log all user agents that access each route the worker is enabled on. These statistics can be viewed by appending /stat to the route you want to view statistics for.

For instance, if you wanted to get the user agent statistics for https://example.org/stat, you would go to https://example.org/stat

Usage

To compile this worker, clone the repository, run npm install followed by npm run build, and put the output from the target directory in the worker console. This worker is subdomain agnostic, so if you want to enable it across the entire site, set the route to *example.com/*

You can preview what the worker would look like by running npm run preview or npm run preview -- --preview-url https://example.com

Development

If you would like to develop your own database application, you can take the source from db.js and use it however you would like. The procedure for connecting to an existing database can be found here. db.js exposes a simple execute function that takes a SQL query as its sole parameter. As the Gateway backend becomes more stable we will support parameters, but for now it's recommended to construct query strings and take care of sanitization yourself.

Intricacies

This worker excludes any route behind a /static path, and the /stat routes are not logged for obvious reasons.

The new Cloudflared feature exposes an endpoint that allows an authenticated user to execute arbitrary SQL.

Existing Demo

There's a resource leaking bug with the database connection, so it may go up and down periodically. You can check to see if it's working at ahrenn.me. It may go up and down periodically as I work on other workers and if either the db instance or the tunnel instance go down.

This will work on any domain, you can try it out for yourself, it'll commit to the same database that hosts the user agent info for any other site using this worker. You also have read/write access to the db with the credentials I've committed to the database, please play nice :)

Keywords

FAQs

Package last updated on 02 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc