5
6/** Set a cookie and keep track of it inflight */
7export function setCookie(c: Context, key: string, value: string) {
8 const inflight = getInflight(c);
9 inflight.set(key, value);
2import { Context } from "npm:hono@3.8.1";
3
4export function getInflight(c: Context) {
5 return InflightCookies.get(c) || new Map();
6}
24
25// TODO: refactor
26export function formatFloat(a: number) {
27 const intPart = Math.floor(a);
28 const remainder = Math.floor((a - intPart) * 100);
17import { html } from "https://esm.town/v/stevekrouse/html?v=5";
18
19export async function examplePost(req: Request) {
20 const { author, name } = extractValInfo(import.meta.url);
21 return html(await article(author, name));
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
2import { set } from "https://esm.town/v/std/set?v=11";
3
4export async function setTemp(temp: Request) {
5 const currentDate = new Date();
6 const timestamp = currentDate.getTime();
1export async function untitled_amethystStork(request: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}
1# Render html by tagged templates
2
3You can use this simple function to compose components, and you can also format the content within html`` elegantly in VSCode.
4
5## Example
Simple functional CSS library for Val Town
A helper function to build a file's email
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.