Skip to content
Open
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
51 changes: 0 additions & 51 deletions .github/workflows/ci.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ Network Trash Folder
Temporary Items
.apdisk

# End of https://www.toptal.com/developers/gitignore/api/macos,go
# End of https://www.toptal.com/developers/gitignore/api/macos,go
.vercel
20 changes: 0 additions & 20 deletions Dockerfile

This file was deleted.

55 changes: 55 additions & 0 deletions api/coffee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { readFileSync, readdirSync } from "node:fs";
import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url";

const __dirname = dirname(fileURLToPath(import.meta.url));

const frames = readdirSync(join(__dirname, "frames"))
.sort()
.map((f) => readFileSync(join(__dirname, "frames", f)));

const ANSI_CLEAR = "\x1b[H\x1b[2J";
const ANSI_RESET = "\x1b[0m";
const ANSI_COLORS = [
"\x1b[1;31m",
"\x1b[1;32m",
"\x1b[1;33m",
"\x1b[1;34m",
"\x1b[1;35m",
"\x1b[1;36m",
];

const FRAME_MS = 100;
const DURATION_MS = 10_000;

const encoder = new TextEncoder();

export default {
fetch() {
let idx = 0;
let interval;

const stream = new ReadableStream({
start(controller) {
interval = setInterval(() => {
const frame = `${ANSI_CLEAR}${ANSI_COLORS[idx % ANSI_COLORS.length]}${frames[idx % frames.length]}${ANSI_RESET}\r\n`;
controller.enqueue(encoder.encode(frame));
idx++;
}, FRAME_MS);

setTimeout(() => {
clearInterval(interval);
controller.enqueue(encoder.encode("no more coffee :(\n"));
controller.close();
}, DURATION_MS);
},
cancel() {
clearInterval(interval);
},
});

return new Response(stream, {
headers: { "Content-Type": "text/event-stream" },
});
},
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions go.mod

This file was deleted.

Empty file removed go.sum
Empty file.
98 changes: 0 additions & 98 deletions main.go

This file was deleted.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
3 changes: 3 additions & 0 deletions public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion static/index.html → public/static.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>☕</text></svg>">
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<title>tiny.coffee</title>
<script defer data-domain="tiny.coffee" src="https://a.reb.gg/js/a.js"></script>
<style>
Expand Down
22 changes: 22 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"rewrites": [
{
"source": "/",
"has": [
{
"type": "header",
"key": "user-agent",
"value": {
"pre": "curl/"
}
}
],
"destination": "/api/coffee"
},
{
"source": "/",
"destination": "/static.html"
}
]
}