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 hosts = { | |
cloudFlare: "https://flosports-video.s3.amazon.com", | |
stackPath: "https://cdn.stackpath.flosports.tv", | |
}; | |
function isStackPath(request: Request): boolean { | |
const url = new URL(request.url); | |
return !!url.hostname.match(/stackpath/); | |
} |
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 flagpole from "flagpole"; | |
import * as ngrok from "ngrok"; | |
flagpole("Just a basic webhook callback", async (suite) => { | |
// Create webhook scenario | |
const webhook = await suite | |
.scenario("Wait for a webhook", "resource") | |
.webhook("GET /foo") | |
.next(async (context) => { | |
context.comment("Webhook was hit!"); |
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 { Injectable } from '@angular/core'; | |
@Injectable({ | |
providedIn: 'root', | |
}) | |
export class PubSub { | |
private topics: { [id: string]: PubSubTopic } = {}; | |
private constructor() {} |
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
addEventListener('fetch', event => event.respondWith(handleRequest(event))); | |
async function handleRequest(event) { | |
const request = event.request; | |
// Parse query string | |
const { searchParams } = new URL(request.url); | |
let qsName = searchParams.get('name'); | |
// If name in query string, add it to kv async | |
if (qsName) { | |
// Run this async to response, but wait for it to complete before terminating |
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 { ExceptionFilter, Catch, ArgumentsHost } from '@nestjs/common'; | |
import { Response } from 'express'; | |
import { IncomingMessage } from 'http'; | |
import { HttpException, HttpStatus } from '@nestjs/common'; | |
export const getStatusCode = (exception: unknown): number => { | |
return exception instanceof HttpException | |
? exception.getStatus() | |
: HttpStatus.INTERNAL_SERVER_ERROR; | |
}; |
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 { NestFactory } from '@nestjs/core'; | |
import { AppModule } from './app.module'; | |
import { GlobalExceptionFilter } from './exception-handler'; | |
async function bootstrap() { | |
const app = await NestFactory.create(AppModule); | |
app.useGlobalFilters(new GlobalExceptionFilter()); | |
await app.listen(3000); | |
} | |
bootstrap(); |
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 variantTemplate = suite.template({ | |
type: "hls", | |
next: { | |
"Should be a VOD with more than one segment": async (context) => { | |
await context.find("type").equals("vod"); | |
const segments = await context.find("segments"); | |
context.assert("There are ts segments", segments).length.greaterThan(1); | |
context | |
.assert("Every Segment URI ends with .ts", segments) | |
.every((segment) => String(segment.uri).endsWith(".ts")); |
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 flagpole from "flagpole"; | |
const masterManifestUrl = "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"; | |
flagpole("HLS Testing Demo", async (suite) => { | |
suite | |
.scenario("Test Big Buck Bunny", "hls") | |
.open(masterManifestUrl) | |
.next(async (context) => { | |
await context.find("type").equals("master"); |
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
class WrappedValue { | |
constructor( | |
public name: string, | |
public value: string | |
) {} | |
} | |
const data: WrappedValue[] = [ | |
new WrappedValue("First Name", "Jason"), | |
new WrappedValue("Last Name", "Byrne") |
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
class WrappedValue<T> { | |
constructor( | |
public name: string, | |
public value: T | |
) {} | |
} | |
const data: WrappedValue[] = [ | |
new WrappedValue<string>("First Name", "Jason"), | |
new WrappedValue<string>("Last Name", "Byrne"), |