Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,7 @@ function fetchConfig() {
// how many visitors should be let in at a time?
//
// default 5
automaticQuantity: 5,

// for demonstration purposes only, how many visitors should be
// added to the queue ahead of a new visitor
//
// default 15, set to 1 for normal behaviour
demoPadding: 15,
automaticQuantity: 5
},
};
}
Expand Down
25 changes: 2 additions & 23 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ const textDecoder = new TextDecoder();
const adminView = textDecoder.decode(includeBytes('src/views/admin.html'));
const queueView = textDecoder.decode(includeBytes('src/views/queue.html'));

// For demo purposes
const demoManifest = textDecoder.decode(includeBytes('src/static/demo-manifest.md'));
const DEMO_THUMBNAIL = includeBytes('src/static/demo-thumb.png');

// The name of the backend serving the content that is being protected by the queue.
const CONTENT_BACKEND = "protected_content";

Expand All @@ -54,22 +50,6 @@ async function handleRequest(event) {
const { request, client } = event;
const url = new URL(request.url);

// Metadata foe developer.fastly.com.
// Feel free to delete this.
if (url.pathname == "/.well-known/fastly/demo-manifest") {
return new Response(demoManifest, {
status: 200,
headers: {
"Content-Type": "text/markdown",
},
});
} else if (url.pathname == "/demo-thumb.png") {
return new Response(DEMO_THUMBNAIL, {
status: 200,
headers: { 'content-type': 'image/png' }
});
}

// Allow requests to assets that are not protected by the queue.
if (ALLOWED_PATHS.includes(url.pathname)) {
let resp = await handleAuthorizedRequest(request);
Expand Down Expand Up @@ -124,11 +104,10 @@ async function handleRequest(event) {
if (payload && isValid) {
visitorPosition = payload.position;
} else {
// Add a new visitor to the end of the queue.
// If demo padding is set in the config, the queue will grow by that amount.
// Add 1 new visitor to the end of the queue.
visitorPosition = await incrementQueueLength(
redis,
config.queue.demoPadding ? config.queue.demoPadding : 1
1
);

// Sign a JWT with the visitor's position.
Expand Down
44 changes: 0 additions & 44 deletions src/static/demo-manifest.md

This file was deleted.

Binary file removed src/static/demo-thumb.png
Binary file not shown.