This file contains hidden or 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 Home() { | |
| function refresh(e) { | |
| e.preventDefault(); | |
| window.location.reload(); | |
| } | |
| const {data, error} = useSWR("api/data", fetcher) | |
| if (error) return "An error has occurred."; | |
| if (!data) return "Loading..."; | |
| return ( | |
| <div className={styles.container}> |
This file contains hidden or 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 'ioredis' | |
| let redis = new Redis(process.env.REDIS_URL) | |
| export default async (req, res) => { | |
| let start = Date.now(); | |
| let cache = await redis.get("cache") | |
| cache = JSON.parse(cache) | |
| let result = {} | |
| if (cache) { |
This file contains hidden or 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 RateLimiter = require('async-ratelimiter') | |
| const Redis = require('ioredis') | |
| const { getClientIp } = require('request-ip') | |
| const rateLimiter = new RateLimiter({ | |
| db: new Redis("YOUR_REDIS_URL"), | |
| max: 1, | |
| duration: 5_000 | |
| }) |
This file contains hidden or 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 '../styles/globals.css' | |
| import { | |
| ApolloClient, | |
| ApolloProvider, createHttpLink, InMemoryCache, | |
| } from "@apollo/client"; | |
| const link = createHttpLink({ | |
| uri: "https://graphql-us-east-1.upstash.io/", | |
| headers: { | |
| Authorization: "Bearer YOUR_ACCESS_TOKEN", | |
| }, |
This file contains hidden or 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 styles from '../styles/Home.module.css' | |
| import { | |
| gql, useQuery, | |
| } from "@apollo/client"; | |
| import React from "react"; | |
| const GET_COIN_LIST = gql` | |
| query { |