pomdtr-val_town_cmdk.web.val.run
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: {
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
v75
May 4, 2024