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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { api } from "https://esm.town/v/pomdtr/api";
import { Action, ActionItem, ListItem, Page } from "https://esm.town/v/pomdtr/cmdk";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
import { trpc } from "https://esm.town/v/pomdtr/trpc";
import { blob } from "https://esm.town/v/std/blob?v=11";
import { Hono } from "npm:hono";
import { bearerAuth } from "npm:hono/bearer-auth";
const valForm = (title: string, values?: {
name?: string;
code?: string;
privacy?: string;
}) => {
const page: Page = {
type: "form",
title,
form: {
items: [
{
title: "Name",
name: "name",
type: "text",
text: {
value: values?.name,
placeholder: "Val Name.",
},
},
{
title: "Code",
name: "code",
type: "textarea",
textarea: {
placeholder: "Val Code.",
value: values?.code,
},
},
{
title: "Privacy",
name: "privacy",
type: "select",
select: {
value: values?.privacy,
options: [
{
title: "Public",
value: "public",
},
{
title: "Unlisted",
value: "unlisted",
},
{
title: "Private",
value: "private",
},
],
},
},
],
},
};
return page;
};
const app = new Hono();
app.use(
"*",
bearerAuth({
verifyToken: async (token) => {
return token === Deno.env.get("CMDK_TOKEN");
},
}),
);
app.get("/", async (c) => {
const val = extractValInfo(import.meta.url);
const page: Page = {
type: "list",
title: "Val Town",
list: {
items: [
{
title: "Search Vals",
actions: [
{
type: "push",
push: {
page: "/vals/search",
},
},
],
},
{
title: "Create Val",
actions: [
{
type: "push",
push: {
1
2
3
4
5
6
import { trpc } from "https://esm.town/v/pomdtr/trpc";
const res = await trpc.mutate("deleteVal", {
valNameId: "4ba1c430-e863-11ee-b32d-8aad37b30b4b",
});
console.log(res);
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
import { Hono } from "npm:hono";
export function githubExtension({
token: string,
}) {
const app = new Hono();
app.get("/", (c) => {
return c.json({
type: "list",
list: {
items: [
{
"title": "Search Repositories"
}
]
}
})
});
app.get("/repos/search", (c) => {
return {
type: "list",
list: {
items: []
}
}
})
return app.fetch
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { Command } from "https://esm.town/v/pomdtr/cmdk";
import { trpc } from "https://esm.town/v/pomdtr/trpc";
export const getValLogs: Command = async (ctx) => {
const logs = await trpc.query("getValLastLogs", {
valNameId: ctx.params.val,
});
return {
type: "detail",
detail: {
markdown: ["```json", JSON.stringify(logs, null, 2), "```"].join("\n"),
actions: [],
},
};
};
1
Next