-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from anna-murphy/fixes
Fixes
- Loading branch information
Showing
18 changed files
with
149 additions
and
345 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
{ | ||
"indexes": [], | ||
"indexes": [ | ||
{ | ||
"collectionGroup": "rss", | ||
"queryScope": "COLLECTION", | ||
"fields": [ | ||
{ | ||
"fieldPath": "feed", | ||
"order": "ASCENDING" | ||
}, | ||
{ | ||
"fieldPath": "timestamp", | ||
"order": "DESCENDING" | ||
} | ||
] | ||
} | ||
], | ||
"fieldOverrides": [] | ||
} |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const LOCATIONS = { | ||
cf: "https://us-central1-capes-in-the-dark.cloudfunctions.net/", | ||
capes: "https://capes-in-the-dark.web.app/", | ||
local: "localhost:5001/capes-in-the-dark/us-central1/", | ||
} as const; | ||
|
||
const ENDPOINTS = { | ||
ping: "ping", | ||
citwm: "capes-in-the-west-march/rss.xml", | ||
} as const; | ||
|
||
type LocationKeys = keyof typeof LOCATIONS; | ||
type Locations = (typeof LOCATIONS)[keyof typeof LOCATIONS]; | ||
type EndpointKeys = keyof typeof ENDPOINTS; | ||
type Endpoints = (typeof ENDPOINTS)[keyof typeof ENDPOINTS]; | ||
type Url = `${Locations}${Endpoints}`; | ||
|
||
function help(): void { | ||
if (process.argv.includes("-h") || process.argv.includes("help")) { | ||
console.log( | ||
"Fetch an API endpoint. Specify locations and endpoints via args", | ||
); | ||
console.log( | ||
`\tLocations: [${Object.keys(LOCATIONS).join(", ")}] (default: ${"cf"})`, | ||
); | ||
console.log( | ||
`\tEndpoints: [${Object.keys(ENDPOINTS).join(", ")}] (default: ${"ping"})`, | ||
); | ||
process.exit(); | ||
} | ||
} | ||
|
||
function validateLocation(): LocationKeys { | ||
const validLocations = Object.keys(LOCATIONS); | ||
for (const arg of process.argv.map((arg) => arg.toLowerCase())) { | ||
if (validLocations.includes(arg)) return arg as LocationKeys; | ||
} | ||
console.log("No valid location argument found - defaulting to cf"); | ||
return "cf" as LocationKeys; | ||
} | ||
|
||
function validateEndpoint(): EndpointKeys { | ||
const validEndpoints = Object.keys(ENDPOINTS); | ||
for (const arg of process.argv.map((arg) => arg.toLowerCase())) { | ||
if (validEndpoints.includes(arg)) return arg as EndpointKeys; | ||
} | ||
console.log("No valid endpoint argument found - defaulting to ping"); | ||
return "ping" as EndpointKeys; | ||
} | ||
|
||
async function doFetch(url: Url): Promise<void> { | ||
console.log(`Fetch: ${url}`); | ||
const resp = await fetch(url); | ||
console.log(`Status: ${resp.status}`); | ||
const text = await resp.text(); | ||
console.log(text); | ||
} | ||
|
||
function main(): void { | ||
help(); | ||
void doFetch( | ||
`${LOCATIONS[validateLocation()]}${ENDPOINTS[validateEndpoint()]}`, | ||
); | ||
} | ||
|
||
main(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { firestore } from "./utils/firebaseProduction"; | ||
|
||
async function main(): Promise<void> { | ||
const rssDocs = await firestore | ||
.collection("api/v1/rss") | ||
.where("feed", "==", "Capes in the West March") | ||
.orderBy("timestamp", "desc") | ||
.get(); | ||
for (const doc of rssDocs.docs) { | ||
console.log(doc.data()); | ||
} | ||
} | ||
|
||
main() | ||
.then(() => { | ||
console.log("done"); | ||
}) | ||
.catch(console.error); |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,6 @@ export function Upload(): JSX.Element { | |
} | ||
*/ | ||
|
||
|
||
import { | ||
FileInput, | ||
NumberInput, | ||
|
Oops, something went wrong.