Skip to content

Instantly share code, notes, and snippets.

View CyberClarence's full-sized avatar
🎯
Getting Shit Done

CyberClarence

🎯
Getting Shit Done
View GitHub Profile
@CyberClarence
CyberClarence / db.ts
Created May 4, 2024 23:00
CloudFlare D1 Web Worker HTTP Proxy
/**
* Welcome to Cloudflare Workers! This is your first worker.
*
* - Run `npm run dev` in your terminal to start a development server
* - Open a browser tab at http://localhost:8787/ to see your worker in action
* - Run `npm run deploy` to publish your worker
*
* Bind resources to your worker in `wrangler.toml`. After adding bindings, a type definition for the
* `Env` object can be regenerated with `npm run cf-typegen`.
*
export class D1ProxyClient {
private workerUrl: string;
private apiKey: string;
constructor(workerUrl: string, apiKey: string) {
this.workerUrl = workerUrl;
this.apiKey = apiKey;
}
async query(sql: string, params: any[] = []) {
const response = await fetch(this.workerUrl, {
method: "POST",
- mettre en place le cycle de vie de ton projet post-MVP
- réduire les coûts techniques dans vos process déjà existants (développement & infra)
- auditer la sécurité de vos applications (API, app web, mobile & de bureau)
- former vos équipes techniques
  • Next14 (app router) deployed on Cloudflare Page
  • Tailwind for UI
  • Cloudflare D1 Database with DrizzleORM
  • OpenAI (GPT3.5 Turbo)
  • Namecheap for domain names
  • Scaleway Transactional Email Service
  • Mixpanel for Analytics
  • Sentry for Production Error catching
  • Github to host my code
  • Stripe for paywalls
function generateRandomIPv6() {
const getRandomHexSegment = () => Math.floor(Math.random() * 0x10000).toString(16).padStart(4, '0'); // Generates a random 4-digit hexadecimal segment
// Generate 8 segments and join them with colons
return `${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}:${getRandomHexSegment()}`;
}
(async () => {
let requestCount = 0; // Initialize request count
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); // Delay function
BUN_VERSION="1.1.29"
don't forget to encrypt the value