Search
![sharetru avatar](https://images.clerk.dev/oauth_github/img_2ShcjCQQpI42nE2fubbpZhrGtAS.jpeg)
myApi
@sharetru
An interactive, runnable TypeScript val by sharetru
Script
export function myApi(name) {
return "hi " + name;
eventsInNYC
@synco
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
// ... other existing events
function EventSubmissionForm({ onSubmit }) {
const [formData, setFormData] = useState({
</form>
function EventCard({ event, onFeedback }) {
const [showFeedback, setShowFeedback] = useState(false);
</div>
function App() {
const [events, setEvents] = useState(INITIAL_EVENTS);
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
// Handle event submission
![saolsen avatar](https://images.clerk.dev/oauth_github/img_2QtXHzN3gDPhKsBOvKsst8LTxC5.png)
tracing
@saolsen
Opentelemetry Tracing for Vals! Enables Opentelemetry tracing for vals.
Exports two functions, init and traced_handler .
init will set up opentelemetry. For how to use it see this example val . By default, traces log to the console but if you set HONEYCOMB_API_KEY it'll also push the traces to honeycomb.
In the future we can add more export targets for other services. I'm also thinking about making a val to display them. traced_handler is a wrapper for your handler you can use on an HTTP val. Just pass it your HTTP function and export it as the default and it'll trace every request. Here's a screenshot of what the honeycomb view of a trace from my connect playing val looks like.
Script
Exports two functions, `init` and `traced_handler`.
`traced_handler` is a wrapper for your handler you can use on an HTTP val. Just pass it your HTTP function and export it as the default and it'll trace every request.
export function get_tracer() {
export function init(service_name: string, console_log: bool = false): undefined {
* so if you are calling another val that uses traced_handler their traces will
export async function traced_fetch(
* Wrapper to trace a function.
* @returns {Function} A new handler that traces the request.
export function traced_handler(
async function _traced_hander(req: Request): Promise<Response> {
myApi
@devgio
An interactive, runnable TypeScript val by devgio
Script
export function myApi(name) {
return "hi " + name;
![tylergaw avatar](https://images.clerk.dev/oauth_github/img_2RlAffcLz76puXiI2qjVVXC8i20.jpeg)
myApi
@tylergaw
An interactive, runnable TypeScript val by tylergaw
Script
export function myApi(name) {
return "Hello " + name;
![pomdtr avatar](https://images.clerk.dev/oauth_github/img_2RCoAITJZH1QencEgtVjh4Qirj4.jpeg)
lastlogin
@pomdtr
Lastlogin Authentication for val.town Looking for an hono integration ? See @pomdtr/lastloginHono Support login in trough: Email Link QR Code Google Oauth Github Oauth Gitlab Oauth Facebook Oauth Demo You can try a demo at https://pomdtr-lastloginhonoexample.web.val.run (see @pomdtr/lastLoginHonoExample for code) Usage Wrap your http handlers in a lastlogin middleware (sessions will be persisted in the lastlogin_session table on your sqlite account). If you want to be the only one able to access your val, you can use @pomdtr/verifyUserEmail. import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin";
import { verifyUserEmail } from "https://esm.town/v/pomdtr/verifyUserEmail";
export default lastlogin((req) => {
return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`);
}, {
// check that the user email match your val town email
verifyEmail: verifyUserEmail
}); If you want to customize how is allowed to signup, you can set the verifyEmail option: import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin";
export default lastlogin((req) => {
return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`);
}, {
verifyEmail: (email) => { email == "steve@valtown" }
}); You can allow anyone to signup by returning a boolean from the verifyEmail function: import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin";
export default lastlogin((req) => {
return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`);
}, {
verifyEmail: (_email) => true
}); Public Routes import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin";
import { verifyUserEmail } from "https://esm.town/v/pomdtr/verifyUserEmail";
export default lastlogin(() => {
return new Response("Hi!");
}, {
verifyEmail: verifyUserEmail,
public_routes: ["/", "/public/*"],
}); See the URLPattern API for reference. Logout Just redirect the user to /auth/logout
Script
verifyEmail: (email) => { email == "steve@valtown" }
You can allow anyone to signup by returning a boolean from the verifyEmail function:
```ts
import { deleteCookie, getCookies, setCookie } from "jsr:@std/http/cookie";
async function createSession(email: string, hostname: string) {
const sessionID = crypto.randomUUID();
return sessionID;
async function getSession(sessionID: string, hostname: string) {
try {
return null;
async function deleteSession(sessionID: string) {
await sqlite.execute({
public_routes?: string[];
export function lastlogin(
handler: (req: Request) => Response | Promise<Response>,
valle_tmp_995925833637146645728378117787845
@janpaul123
// This val simply responds with "Hello world" on every HTTP request
HTTP
// This val simply responds with "Hello world" on every HTTP request
export default async function main(req: Request): Promise<Response> {
return new Response("Hello world");
sqliteExplorerApp_DEV
@nbbaier
SQLite Explorer (Dev Branch) View and interact with your Val Town SQLite data. It's based off Steve's excellent SQLite Admin val, adding the ability to run SQLite queries directly in the interface. This new version has a revised UI and that's heavily inspired by LibSQL Studio by invisal . This is now more an SPA, with tables, queries and results showing up on the same page. Install Install the latest stable version (v66) by forking this val: Authentication Login to your SQLite Explorer with password authentication with your Val Town API Token as the password. Todos / Plans [ ] improve error handling [ ] improve table formatting [ ] sticky table headers [x] add codemirror [ ] add loading indication to the run button (initial version shipped) [ ] add ability to favorite queries [ ] add saving of last query run for a table (started) [ ] add visible output for non-query statements [ ] add schema viewing [ ] add refresh to table list sidebar after CREATE/DROP/ALTER statements [ ] add automatic execution of initial select query on double click [x] add views to the sidebar [ ] add triggers to sidebar [ ] add upload from SQL, CSV and JSON [ ] add ability to connect to a non-val town Turso database [x] fix wonky sidebar separator height problem (thanks to @stevekrouse) [x] make result tables scrollable [x] add export to CSV, and JSON (CSV and JSON helper functions written in this val . Thanks to @pomdtr for merging the initial version!) [x] add listener for cmd+enter to submit query
HTTP
- [x] make result tables scrollable
- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
- [x] add listener for cmd+enter to submit query
![stevekrouse avatar](https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg)
verifyAPIAuth
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { importKey } from "https://esm.town/v/stevekrouse/importKey";
import { getPublicKey } from "https://esm.town/v/stevekrouse/getPublicKey";
export async function verifyAPIAuth({ signature, ...signed }) {
let { handle, t } = signed;
let publicKey = await getPublicKey(handle);
![stevekrouse avatar](https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg)
pexelsExample
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
import { html } from "https://esm.town/v/stevekrouse/html";
import { createClient } from "npm:pexels";
export async function pexelsExample(request: Request): Promise<Response> {
const pexels = createClient(Deno.env.get("pexels"));
const r = await pexels.photos.search({ query: "singapore skyline" });
![markos avatar](https://images.clerk.dev/oauth_github/img_2RT1O0ZwFlRvDsiMgbLSxNuNTUh.png)
myApi
@markos
An interactive, runnable TypeScript val by markos
Script
export function myApi(name) {
return "hi " + name;
sqliteExplorerApp
@iamseeley
SQLite Explorer View and interact with your Val Town SQLite data. It's based off Steve's excellent SQLite Admin val, adding the ability to run SQLite queries directly in the interface. This new version has a revised UI and that's heavily inspired by LibSQL Studio by invisal . This is now more an SPA, with tables, queries and results showing up on the same page. Install Install the latest stable version (v81) by forking this val: Authentication Login to your SQLite Explorer with password authentication with your Val Town API Token as the password. Todos / Plans [ ] improve error handling [ ] improve table formatting [ ] sticky table headers [x] add codemirror [ ] add loading indication to the run button (initial version shipped) [ ] add ability to favorite queries [ ] add saving of last query run for a table (started) [ ] add visible output for non-query statements [ ] add schema viewing [ ] add refresh to table list sidebar after CREATE/DROP/ALTER statements [ ] add automatic execution of initial select query on double click [x] add views to the sidebar [ ] add triggers to sidebar [ ] add upload from SQL, CSV and JSON [ ] add ability to connect to a non-val town Turso database [x] fix wonky sidebar separator height problem (thanks to @stevekrouse) [x] make result tables scrollable [x] add export to CSV, and JSON (CSV and JSON helper functions written in this val . Thanks to @pomdtr for merging the initial version!) [x] add listener for cmd+enter to submit query
HTTP
- [x] make result tables scrollable
- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
- [x] add listener for cmd+enter to submit query
easygoingEmeraldGamefowl
@toowired
// Test starting a new goal
Script
return { success: false, error: error.message };
// Export for Val Town
export async function test(args) {
return await runTests();