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
let API_ROOT = "" | |
if (location.hostname == "127.0.0.1" || location.hostname == "localhost") { | |
API_ROOT = `https://localhost:5001/${firebaseConfig.projectId}/us-central1` | |
}else{ | |
API_ROOT = `https://us-central1-${firebaseConfig.projectId}.cloudfunctions.net` | |
} | |
fetch(API_ROOT+"/api/sentences", { | |
method: "GET" | |
}).then((response) => console.log(response.json())) |
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
{ | |
"hosting": { | |
"public": "public", | |
"ignore": [ | |
"firebase.json", | |
"**/.*", | |
"**/node_modules/**" | |
], | |
"rewrites": [{ | |
"source": "/api/**", |
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
{ | |
"hosting": { | |
"public": "public", | |
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"], | |
"rewrites": [ | |
{ | |
"source": "/api/**", | |
"function": "api" | |
}, | |
{ |
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 router = require("express").Router() | |
router.get("/list", (req, res) => { | |
res.send(`this is /list on userRoute`) | |
}) | |
router.get("/", (req, res) => { | |
res.send(`this is / on userRoute`) | |
}) |
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 functions = require("firebase-functions") | |
const cors = require("cors") | |
exports.iowa = functions.region("us-central1").https.onRequest((req, res) => { | |
return cors()(req, res, () => { | |
res.send("Hi from Iowa, USA") | |
}) | |
}) | |
exports.london = functions |
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
console.time("London") | |
fetch("https://europe-west2-[project-id].cloudfunctions.net/london").then( async (res)=>{ | |
await console.log(res.text) | |
}) | |
console.timeEnd("London") | |
console.time("Iowa") | |
fetch("https://us-central1-[project-id].cloudfunctions.net/iowa").then( async (res)=>{ | |
await console.log(res.text) | |
}) |
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 Constants from "./constants" | |
let localeSelect = document.querySelector<HTMLSelectElement>("#locale-select") | |
Constants.localeList.forEach((locale) => { | |
localeSelect?.add(new Option(locale.label, locale.value)) | |
}) |
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
interface Locale { | |
label: string | |
value: string | |
} | |
interface Constants { | |
localeList: Array<Locale> | |
} | |
let CONSTANTS: Constants = { |
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
Show hidden characters
{ | |
"compilerOptions": { | |
/* Visit https://aka.ms/tsconfig.json to read more about this file */ | |
/* Basic Options */ | |
// "incremental": true, /* Enable incremental compilation */ | |
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ | |
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | |
// "lib": [], /* Specify library files to be included in the compilation. */ | |
"allowJs": true, /* Allow javascript files to be compiled. */ |
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 * as Const from "./const" | |
import * as JsConst from "./jsconst" | |
import superheroes from "superheroes" | |
const label = document.querySelector<HTMLElement>("#label") | |
label!.innerHTML = Const.default | |
console.log(JsConst.default) |