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 { Auth } from './auth'; | |
addEventListener('fetch', (event: StackPathEvent) => { | |
event.respondWith(handleRequest(event.request)); | |
}); | |
async function handleRequest(request: StackPathRequest): Promise<Response> { | |
try { | |
const auth: Auth = new Auth(request); | |
if (!auth.isAuthenticated()) { |
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
{ | |
"name": "functions", | |
"scripts": { | |
"lint": "tslint --project tsconfig.json", | |
"build": "tsc", | |
"serve": "npm run build && firebase serve --only functions", | |
"shell": "npm run build && firebase functions:shell", | |
"start": "npm run shell", | |
"deploy": "firebase deploy --only functions", | |
"logs": "firebase functions:log" |
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 { Flagpole } = require('flagpole'); | |
const searchTerm = 'Flagpole QA'; | |
const suite = Flagpole.suite('Basic Smoke Test of Site') | |
.base('https://www.google.com'); | |
suite.html('Homepage Loads') | |
.open('/') | |
.next('Test the basic headers', (ctx) => { |
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 { Flagpole } = require('flagpole'); | |
const opts = { | |
headless: false, | |
width: 1280, | |
height: 600 | |
}; | |
const suite = Flagpole.suite('Basic Smoke Test of npmjs.com') | |
.base('https://www.npmjs.com/'); |
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 { Router } from "./helpers/router"; | |
import { getQueryString } from "./helpers/querystring"; | |
const MAGIC_WORD = "flo"; | |
function catchAll(request: Request): Response { | |
return fetch(request.url, request); | |
} | |
function validateTokenThenFetch( |
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
function handleRequest(request: Request): Promise<Response> { | |
return fetch(request); | |
} | |
addEventListener('fetch', (event) => { | |
event.respondWith(handleRequest(event.request)) | |
}); |
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
'use strict'; | |
exports.handler = (event, context, callback) => { | |
const request = event.Records[0].cf.request; | |
return callback(null, request); | |
}; |
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
export async function addCustomHeader(response: Response): Promise<Response> { | |
const modifiedResponse = new Response(response.body, response); | |
modifiedResponse.headers.set("X-My-Custom-Header", "Hello there!"); | |
return modifiedResponse; | |
} |
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
export async function addCustomHeader(response: Response): Promise<Response> { | |
const modifiedResponse = new Response(await response.arrayBuffer(), response); | |
modifiedResponse.headers.set("X-My-Custom-Header", "Hello there!"); | |
return modifiedResponse; | |
} |
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
export async function personalizeBody( | |
response: Response, | |
request: Request | |
): Promise<Response> { | |
const originalBody = await response.text(); | |
const newBody = originalBody.replace( | |
/{{ timestamp }}/g, | |
new Date().toUTCString() | |
); | |
const modifiedResponse = new Response(newBody, response); |