34// Fetch user by username
5export async function getUserByUsername(username: string) {
6const userResult = await sqlite.execute({
7sql: `SELECT id, name, bio, username, email, location, currently_listening, currently_reading_title,
2930// Update user profile
31export async function updateUser(userId, name, bio, location, currentlyListening, currentlyReading, currentlyWatching, profile_theme, profile_img) {
32if (typeof userId !== "number") {
33throw new Error("userId must be a number.");
46}
4748export async function insertUserLink(userId: number, label: string, url: string) {
49await sqlite.execute({
50sql: `INSERT INTO user_links (user_id, label, url) VALUES (?, ?, ?)`,
53}
5455export async function getLinkById(linkId: number) {
56const result = await sqlite.execute({
57sql: `SELECT id, label, url, user_id FROM user_links WHERE id = ?`,
68}
6970export async function updateUserLink(linkId: number, label: string, url: string) {
71await sqlite.execute({
72sql: `UPDATE user_links SET label = ?, url = ? WHERE id = ?`,
75}
7677export async function deleteUserLink(linkId: number, userId: number) {
78await sqlite.execute({
79sql: `DELETE FROM user_links WHERE id = ? AND user_id = ?`,
82}
8384export async function getUserLinks(userId) {
85if (typeof userId !== "number") {
86throw new Error("userId must be a number.");
101}
102103export async function isUsernameTaken(username) {
104const result = await sqlite.execute({
105sql: `SELECT COUNT(*) FROM users WHERE username = ?`,
110}
111112export async function isEmailTaken(email) {
113const result = await sqlite.execute({
114sql: `SELECT COUNT(*) FROM users WHERE email = ?`,
140141142export async function getProfileImageUrl(username) {
143const key = `profile_img/${username}`;
144const imageUrl = await blob.get(key);
4// Make SQLite table to store the count increments (with timestamps)
56export default async function(req: Request): Promise<Response> {
7const result = await sqlite.batch([
8"CREATE TABLE IF NOT EXISTS counter_2_baby (timestamp DATETIME DEFAULT CURRENT_TIMESTAMP)",
getCloudLabCountmain.tsx1 match
4// TODO: Convert to sqlite
56export default async function(req: Request): Promise<Response> {
7const result = await sqlite.execute(
8"SELECT COUNT(*) FROM counter_2_baby",
29}
3031export function createVal({ token, ...data }: { token?: string } & CreateValArgs): Promise<ValResponse> {
32return fetchJSON("https://api.val.town/v1/vals", {
33bearer: token || Deno.env.get("valtown"),
hono_react_ssrmain.tsx1 match
4041export const middleware = (importMetaURL: string) =>
42async function(req: Request): Promise<Response> {
43const { author, name } = extractValInfo(importMetaURL);
44const valURL = `https://www.val.town/v/${author}/${name}`;
linkInBioTemplatemain.tsx1 match
12};
1314export default async function(req: Request) {
15return new Response(
16renderToString(
valTownBadgeExamplemain.tsx1 match
4import { render } from "npm:preact-render-to-string";
56function handler(req: Request): Promise<Response> {
7const body = render(
8<div>
codeIconReactmain.tsx1 match
2import React from "npm:react";
34export default function CodeIcon(props: React.SVGProps<SVGSVGElement>) {
5return (
6<svg
staticChessREADME.md1 match
8Plain, brutalist, no bloat chess. Every page is only html and css. Every chess move is made by clicking a link. Send a link to your friend and they'll send you one back to make your move. No silly animations or slick interactivity to trip up your gameplay. When Google indexes this site will we successfully compute all possible chess moves?
910Functionality is quite limited, and things might be broken. Please let me know if you find bugs!
1112Inspired by [this HN discussion](https://news.ycombinator.com/item?id=39456467) about sites that have all possible game states of tic-tac-toe.
frontmattermain.tsx2 matches
6import { frontmatter } from "npm:micromark-extension-frontmatter";
78export async function extractFrontmatter(readme: string) {
9const tree = await fromMarkdown(readme, {
10extensions: [frontmatter(["yaml"])],
23}
2425export async function extractValFrontmatter(val: { author: string; name: string }) {
26const { readme } = await api<{ readme: string }>(`/v1/alias/${val.author}/${val.name}`);
27return extractFrontmatter(readme);