2import process from "node:process";
3
4export default async function handler(request: Request) {
5 if (request.method !== "POST") {
6 return Response.json({ message: "This val responds to POST requests." }, {
13}
14
15export function UserProfile({ user, onUpdate }: UserProfileProps) {
16 const [username, setUsername] = useState(user.username || "");
17 const [isEditing, setIsEditing] = useState(false);
5export const MAGIC_LINKS_TABLE = "lucia_demo_magic_links_v2";
6
7async function createTables() {
8 await sqlite.execute(`
9 CREATE TABLE IF NOT EXISTS ${USER_TABLE} (
6}
7
8export function LoginForm({ onError }: LoginFormProps) {
9 const [email, setEmail] = useState("");
10 const [isSubmitting, setIsSubmitting] = useState(false);
10};
11
12function MediaMonitoringTab({ user }) {
13 const [entries, setEntries] = useState([]);
14 const [platform, setPlatform] = useState("");
167 };
168
169 // Function to open the edit modal
170 const handleEditClick = (entry) => {
171 setEditingEntry(entry);
187 };
188
189 // Function to close the edit modal
190 const handleCloseEditModal = () => {
191 setIsEditModalOpen(false);
204 };
205
206 // Function to handle changes in the edit modal form
207 const handleEditFormChange = (e) => {
208 const { name, value } = e.target;
213 };
214
215 // Function to save the edited entry
216 const handleSaveEdit = async () => {
217 // Validate required fields from editFormData
2// Click "Run", copy and paste the email address and send an email to it.
3// This example will log the email details received.
4export default async function emailHandler(email: Email){
5 console.log("Email received!", email.from, email.subject, email.text);
6 for (const file of email.attachments) {
2// Configure the timer with the 🕒 icon in the top right.
3// This example just logs the current time.
4export function scheduledHandler() {
5 const timestamp = new Date().toISOString();
6 console.log(`Cron val executed at: ${timestamp}`);
2// Access it via its public URL (you can also pick a nicer subdomain).
3// Try adding ?name=YourName to the URL!
4export default function httpHandler(req: Request): Response {
5 const url = new URL(req.url);
6 const name = url.searchParams.get("name") || "Friend";
1// This script returns a random fun fact
2// You can run scripts manually in this view or call it from other vals.
3export default function getRandomFact() {
4 const funFacts = [
5 "Honey never spoils.",
30}
31
32async function deleteExistingTodoistEvents() {
33 await sqlite.execute(
34 `
43 * @returns Array of Todoist tasks due today or overdue
44 */
45async function fetchTodoistTasks(): Promise<TodoistTask[]> {
46 const apiToken = Deno.env.get("TODOIST_API_TOKEN");
47
87 * @returns Memory object
88 */
89function convertTodoistTaskToMemory(task: TodoistTask): Memory {
90 return {
91 id: task.id.toString(),
101 * Stores Todoist tasks in SQLite database
102 */
103export default async function storeTodoistTasksToMemories() {
104 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
105
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",