Skip to content

Commit

Permalink
Migrate to regional buckets for caching
Browse files Browse the repository at this point in the history
  • Loading branch information
molly committed Jan 31, 2024
1 parent 3d1c799 commit 33a0b17
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 17 deletions.
3 changes: 2 additions & 1 deletion functions/ejs/rss.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<link rel="alternate" href="https://web3isgoinggreat.com" />
<icon>https://web3isgoinggreat.com/favicon-32x32.png</icon>
<webfeeds:icon>https://web3isgoinggreat.com/favicon-32x32.png</webfeeds:icon>
<webfeeds:cover image="https://primary-web3.storage.googleapis.com/entryImages/monkey-og.png"></webfeeds:cover>
<webfeeds:cover image="https://primary-web3-regional.storage.googleapis.com/entryImages/monkey-og.png">
</webfeeds:cover>
<webfeeds:accentColor>5948a4</webfeeds:accentColor>
<category term="technology" />
<rights type="html">CC-BY-SA 3.0</rights>
Expand Down
2 changes: 1 addition & 1 deletion functions/src/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const resizeImage = async ({
};

export const onImageUpload = functions.storage
.bucket("primary-web3")
.bucket("primary-web3-regional")
.object()
.onFinalize(async (object) => {
if (
Expand Down
10 changes: 6 additions & 4 deletions functions/src/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import * as ejs from "ejs";
import { Entry, RssEntry } from "./types";
import axios from "axios";

const STORAGE_URL_PREFIX = "https://primary-web3.storage.googleapis.com";
const STATIC_STORAGE_URL_PREFIX = "https://static-web3.storage.googleapis.com";
const STORAGE_URL_PREFIX =
"https://primary-web3-regional.storage.googleapis.com";
const STATIC_STORAGE_URL_PREFIX =
"https://static-web3-regional.storage.googleapis.com";
const writeFeed = async (xml: string): Promise<void> => {
const file = await storage.bucket("static-web3").file("rss.xml");
const file = await storage.bucket("static-web3-regional").file("rss.xml");
await file.save(xml);
await file.setMetadata({
contentType: "application/atom+xml;charset=UTF-8",
Expand Down Expand Up @@ -66,7 +68,7 @@ export const updateRssOnChange = functions.firestore
let resp;
try {
const stagingFile = await storage
.bucket("static-web3")
.bucket("static-web3-regional")
.file("stagedRss.xml");
await stagingFile.save(xml);
await stagingFile.setMetadata({
Expand Down
6 changes: 4 additions & 2 deletions src/constants/urls.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export const STORAGE_URL = "https://primary-web3.storage.googleapis.com";
export const STATIC_STORAGE_URL = "https://static-web3.storage.googleapis.com";
export const STORAGE_URL =
"https://primary-web3-regional.storage.googleapis.com";
export const STATIC_STORAGE_URL =
"https://static-web3-regional.storage.googleapis.com";
4 changes: 2 additions & 2 deletions src/db/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const app = initializeApp({
authDomain: "web3-334501.firebaseapp.com",
databaseURL: "https://web3-334501-default-rtdb.firebaseio.com",
projectId: "web3-334501",
storageBucket: "primary-web3",
storageBucket: "primary-web3-regional",
messagingSenderId: "645239520683",
appId: "1:645239520683:web:3e90522f06ea69822ce6ee",
});

export const db = getFirestore(app);
export const storage = getStorage(app);
export const staticStorage = getStorage(app, "gs://static-web3");
export const staticStorage = getStorage(app, "gs://static-web3-regional");
4 changes: 2 additions & 2 deletions src/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function CustomApp({ Component, pageProps }) {
<meta
property="og:image"
key="ogimage"
content="https://primary-web3.storage.googleapis.com/monkey-og.png"
content="https://primary-web3-regional.storage.googleapis.com/monkey-og.png"
/>
<meta
property="og:image:alt"
Expand Down Expand Up @@ -85,7 +85,7 @@ function CustomApp({ Component, pageProps }) {
<meta
name="twitter:image"
key="twitterimage"
content="https://primary-web3.storage.googleapis.com/monkey-twitter.png"
content="https://primary-web3-regional.storage.googleapis.com/monkey-twitter.png"
/>
<meta
name="twitter:image:alt"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/archive/[[...id]].js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import BackBar from "../../components/BackBar";
import SimpleHeader from "../../components/SimpleHeader";
import Footer from "../../components/Footer";

const BUCKET_PATH = "https://tweet-archives.storage.googleapis.com";
const BUCKET_PATH = "https://tweet-archives-regional.storage.googleapis.com";

export async function getServerSideProps(context) {
const props = {};
Expand Down
8 changes: 4 additions & 4 deletions src/styles/_fixed-at-bottom.sass
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
height: 28px
border-bottom: 0
border-right: 0
border-image-source: url(https://primary-web3.storage.googleapis.com/flames.gif)
border-image-source: url(https://primary-web3-regional.storage.googleapis.com/flames.gif)
border-image-slice: 16 0
border-image-repeat: repeat

&.no-animate
border-image-source: url(https://primary-web3.storage.googleapis.com/flames.png)
border-image-source: url(https://primary-web3-regional.storage.googleapis.com/flames.png)

&.animate
border-image-source: url(https://primary-web3.storage.googleapis.com/flames.gif)
border-image-source: url(https://primary-web3-regional.storage.googleapis.com/flames.gif)

> div
background-color: $accent
Expand Down Expand Up @@ -95,7 +95,7 @@
.grift-counter
// People with prefers-reduced-motion set can still opt in to the animation, in which case
// .animate will also be set, and this will be overriden by the more specific selector above
border-image-source: url(https://primary-web3.storage.googleapis.com/flames.png)
border-image-source: url(https://primary-web3-regional.storage.googleapis.com/flames.png)

@mixin fixedDarkMode()
.grift-counter, .fixed-at-bottom-button
Expand Down

0 comments on commit 33a0b17

Please sign in to comment.