-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslogans-26sep24.js
49 lines (44 loc) · 1.44 KB
/
slogans-26sep24.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const textList = [
"\"look ma, I don't pay for spotify\"",
"\"to optimize or not to optimize\"",
"\"did you follow the instructions?\"",
"\"hacker!!!\"",
"\"oh, there's a way\"",
"\"what is iOS? You mean iPhone?\"",
"\"my android has had that for years\"",
"\"is that even legal?\"",
"\"yes, really\"",
"\"checks up\"",
"\"snapchat support when?\"",
"\"why is it called that?\"",
"\"randomization isn't real\"",
"\"we're so back\"",
"\"do you even read these?\"",
"\"end of line\"",
"\"greetings, programs\"",
"\"hey there john\"",
"\"apple wouldn't like this\"",
"\"it's not jailbreak\"",
"\"yet another clever quote\"",
];
export default async function server(request: Request): Promise<Response> {
// Enable CORS for Framer
const headers = new Headers({
"Access-Control-Allow-Origin": "*",
"Content-Type": "application/json",
});
// Handle OPTIONS request for CORS preflight
if (request.method === "OPTIONS") {
headers.append("Access-Control-Allow-Methods", "GET, OPTIONS");
headers.append("Access-Control-Allow-Headers", "Content-Type");
return new Response(null, { headers, status: 204 });
}
// Get a random text from the list
const randomIndex = Math.floor(Math.random() * textList.length);
const randomText = textList[randomIndex];
// Create the response object
const responseBody = {
text: randomText,
};
return new Response(JSON.stringify(responseBody), { headers });
}