Skip to content

Instantly share code, notes, and snippets.

View fredriccliver's full-sized avatar
🧭
To the north

Fredric Cliver fredriccliver

🧭
To the north
View GitHub Profile
exports.getUsers = functions.https.onCall((data, context) => {
return new Promise((resolve, reject) => {
db.collection("users")
.get()
.then((snapshot) => {
if(snapshot.empty){
reject({msg: "There is no users at all"})
}
data = snapshot.docs.map(doc => doc.data())
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev-server": "webpack-dev-server"
},
"keywords": [],
"author": "",
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "es2015" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"lib": [
"es5","DOM"
const path = require("path")
module.exports = {
mode: "development",
watch: true,
devtool: "eval-source-map",
entry: {
index: "./src/index.ts",
contact: "./src/contact.ts"
},
module: {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="label"></div>
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)
{
"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. */
interface Locale {
label: string
value: string
}
interface Constants {
localeList: Array<Locale>
}
let CONSTANTS: Constants = {
import Constants from "./constants"
let localeSelect = document.querySelector<HTMLSelectElement>("#locale-select")
Constants.localeList.forEach((locale) => {
localeSelect?.add(new Option(locale.label, locale.value))
})
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)
})