Skip to content

Commit 5c694ad

Browse files
committed
hiccups test
1 parent a600a4e commit 5c694ad

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

fresh.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import * as $_404 from "./routes/_404.tsx";
66
import * as $_app from "./routes/_app.tsx";
7+
import * as $api_hiccup from "./routes/api/hiccup.ts";
78
import * as $api_json from "./routes/api/json.ts";
89
import * as $index from "./routes/index.tsx";
910
import * as $partials_live from "./routes/partials/live.tsx";
@@ -19,6 +20,7 @@ const manifest = {
1920
routes: {
2021
"./routes/_404.tsx": $_404,
2122
"./routes/_app.tsx": $_app,
23+
"./routes/api/hiccup.ts": $api_hiccup,
2224
"./routes/api/json.ts": $api_json,
2325
"./routes/index.tsx": $index,
2426
"./routes/partials/live.tsx": $partials_live,

islands/Hiccups.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
1+
const kv = await Deno.openKv();
2+
//kv.set(["hiccups", "alltime"], "1");
3+
const hiccups = await kv.get(["hiccups", "alltime"]);
24
export default function Hiccup() {
5+
6+
console.log(hiccups)
37
return (
48
<div class="flex flex-col items-center">
59
<p>26</p>
610
<div dangerouslySetInnerHTML={{ __html: `
711
<button onclick="playAudio()" type="button">Click here to Hiccup</button>`
812
}} />
13+
<p>Global Hiccup counter: {hiccups.value}</p>
914
</div>
1015
)
1116
}

islands/LastLive.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default function LastLive() {
9090
else {
9191
return (
9292
<div class="flex flex-col items-center">
93-
<a href={live_link}>{months} {days} days, {hours} hours, {minutes} minutes, {seconds} seconds without Yumemi (on {latest.value})</a>
93+
<a href={live_link}>{months} {days} days, {hours} hours, {minutes} minutes, {seconds} seconds without Yumemi</a>
9494
</div>
9595
);
9696
}

routes/api/hiccup.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { FreshContext } from "$fresh/server.ts";
2+
const kv = await Deno.openKv();
3+
const hiccups = await kv.get(["hiccups", "alltime"]);
4+
export const handler = (_req: Request, _ctx: FreshContext): Response => {
5+
console.log("test")
6+
kv.set(["hiccups", "alltime"], hiccups.value + 1);
7+
return new Response(hiccups.value);
8+
};

0 commit comments

Comments
 (0)