Skip to content

Instantly share code, notes, and snippets.

View saifalfalah's full-sized avatar
💻
Working

⚡ Saif Al Falah saifalfalah

💻
Working
View GitHub Profile
@saifalfalah
saifalfalah / country-detector.js
Last active April 4, 2021 14:55
Detecting country using Cloudflare Workers
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
const countries = {
US: "USA",
CA: "CAN",
FR: "FRA",
DE: "DEU",
NL: "NLD",
@saifalfalah
saifalfalah / begin-data.js
Last active April 29, 2020 02:47
begin data test
let arc = require("@architect/functions");
let parseBody = arc.http.helpers.bodyParser;
const data = require("@begin/data");
exports.handler = async function http(req) {
let body = parseBody(req);
let cart = body.cart;
// cart is of the form: { cc1: 1, cc2: 2, cc3: 3, cc4: 4, cc5: 5 }