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
<html> | |
<body> | |
<div class="question"> | |
Q1: What is fun? | |
</div> | |
<div> | |
<input type="radio" id="a0" name="question0"> | |
<label for="a0">Going for a walk</label> | |
</div> | |
<div> |
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
// Make sure to use firebase-admin and to initialize the app | |
const admin = require('firebase-admin') | |
admin.initializeApp(functions.config().firebase) | |
// Example of how I'm GETTING all the records in a collection AND using | |
// the ID from the path of the document that triggered this function | |
exports.getLessonsAsync = functions.firestore | |
.document('organizations/{organizationId}/lessons/{lessonId}') | |
.onWrite(async function(change, context) { | |
const result = await admin |
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
// Using promise | |
const listRef = storage | |
.ref('screenshots/abc123.png') | |
.getDownloadURL() | |
.then((response) => { | |
// Found it. Do whatever | |
}) | |
.catch((err) => { | |
// Didn't exist... or some other 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
const functions = require('firebase-functions') | |
const admin = require('firebase-admin') | |
admin.initializeApp(functions.config().firebase) | |
const SENDGRID_API_KEY = functions.config().sendgrid.key | |
const sendGridEmail = require('@sendgrid/mail') | |
sendGridEmail.setApiKey(SENDGRID_API_KEY) |
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
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "chrome", | |
"request": "attach", | |
"name": "attach to Chrome", | |
"port": 9222, | |
"webRoot": "${workspaceFolder}", | |
"sourceMapPathOverrides": { |
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
/* | |
** Build configuration | |
*/ | |
build: { | |
/* | |
** You can extend webpack config here | |
*/ | |
extend(config, ctx) { | |
if (ctx.isDev) { | |
config.devtool = ctx.isClient ? 'source-map' : 'inline-source-map' |
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
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "chrome", | |
"request": "launch", | |
"name": "client: chrome", | |
"url": "http://localhost:3000", | |
"webRoot": "${workspaceFolder}", | |
"sourceMapPathOverrides": { |
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
addEventListener('fetch', event => { | |
event.passThroughOnException() | |
event.respondWith(handleRequest(event.request)) | |
}) | |
async function handleRequest(request) { | |
const maxBizId = await MIGRATION_SETTINGS.get('maxbizid') | |
const currentBusinessId = getBusinessIdFromCookie(request) | |
if (!maxBizId || maxBizId == 0 || !currentBusinessId) { |
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
// NOTE: all auth code has been removed for the sake of brevity. Please see part 2 of blog series | |
// for more info: https://liftcodeplay.com/2018/10/16/pushing-my-api-to-the-edge-part-2-authentication-and-authorization/ | |
addEventListener('fetch', event => { | |
event.respondWith(handleRequest(event)) | |
}) | |
const genderFemale = 'Female' | |
const genderMale = 'Male' | |
/** |
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
addEventListener('fetch', event => { | |
event.respondWith(handleRequest(event)) | |
}) | |
/** | |
* Entry point of the worker | |
*/ | |
async function handleRequest(event) { | |
// Generate the CORS headers I'll have to return with requests | |
const corsHeaders = setCorsHeaders(new Headers()) |
NewerOlder