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
let counter = 0; | |
exports.handler = async (event) => { | |
counter++; | |
return { | |
statusCode: 200, | |
body: JSON.stringify(counter), | |
}; | |
}; |
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 HLS = require('hls-parser'); | |
const request = require('request'); | |
const URL = require('url').URL | |
// Error codes | |
const ERROR = { | |
INVALID_PLAYLIST_URL: { | |
code: 100, | |
message: 'Invalid playlist URL' | |
}, |
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
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 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 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 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 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 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 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 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; | |
} |