This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Redis } from "@upstash/redis/cloudflare"; | |
import { MultiRegionRatelimit } from "@upstash/ratelimit"; | |
export interface Env { | |
} | |
const cache = new Map(); | |
export default { | |
async fetch( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const fetch = require('node-fetch'); | |
const assert = require('assert'); | |
const helper = require('../helper'); | |
var { | |
serverAddress, | |
headers | |
} = require('../config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function handler(req, res) { | |
fetch("https://full-mantis-14289-us1-rest-kafka.upstash.io/produce/newtopic/MESSAGE", { | |
headers: { | |
Authorization: "Basic Wm5Wc2JDMXRZVzUwYVhNdE1UUXlPVDlUR2szT0ZkabXRvYWxYbm9ldTlUalFG5qZlNLd1X3lBcTRUUEdkOWM2SmJxZlE9PQ==" | |
} | |
}).then(response => response.json()) | |
.then(data => { | |
console.log(data) | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { parse } from 'cookie' | |
import { auth, dbsize, get, setex } from '@upstash/redis' | |
auth(UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN) | |
addEventListener('fetch', (event) => { | |
event.respondWith( | |
handleRequest(event.request).catch( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logo from './logo.svg'; | |
import './App.css'; | |
import {ToastContainer, toast} from 'react-toastify'; | |
import 'react-toastify/dist/ReactToastify.css'; | |
import {useEffect} from "react"; | |
function App() { | |
useEffect(() => { | |
async function fetchData() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Head from 'next/head' | |
import Image from 'next/image' | |
import styles from '../styles/Home.module.css' | |
import {useEffect, useState} from "react"; | |
export default function Home() { | |
const [data, setData] = useState([]); | |
const [loading, setLoading] = useState(false); | |
const [todo, setTodo] = useState(""); | |
let changeHandler = (event) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express') | |
var parseurl = require('parseurl') | |
var session = require('express-session') | |
const redis = require('redis') | |
var RedisStore = require('connect-redis')(session) | |
var client = redis.createClient ({ | |
// REPLACE HERE | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Redis = require("ioredis"); | |
require('dotenv').config() | |
console.log("EDGE analytics with CloudFlare Workers and Upstash Redis.") | |
let redis = new Redis(process.env.REDIS_URL); | |
let dateArg = process.argv[2] | |
let datestr; | |
if (dateArg) { | |
datestr = dateArg; | |
} else { | |
let d = new Date(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const endpoint = 'REPLACE_UPSTASH_REST_ENDPOINT' | |
const token = 'REPLACE_UPSTASH_REST_TOKEN' | |
async function recordRequest(request) { | |
let d = new Date(); | |
let datestr = d.getFullYear() + "-" + (d.getMonth()+1) + "-" + d.getDate(); | |
let data = [["url", request.url], ...request.headers] | |
let url = endpoint + '/lpush/' + datestr | |
const init = { | |
body: JSON.stringify(data), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
NewerOlder