Search

Results include substring matches and semantically similar vals. Learn more
pomdtr avatar
chill
@pomdtr
@jsxImportSource https://esm.sh/hono/jsx
Script
/** @jsxImportSource https://esm.sh/hono/jsx */
type HandlerItem = (ctx: Context) => Response | JSX.Element | Promise<Response> | Promise<JSX.Element>;
type Handler = HandlerItem | {
[method: string]: HandlerItem;
export function createRoute(handler: Handler) {
return async (ctx: Context) => {
if (typeof handler == "object") {
const method = ctx.req.method;
if (!(method in handler)) {
throw new HTTPException(405);
yawnxyz avatar
simpleLogin
@yawnxyz
// Your routes go here
HTTP (deprecated)
const app = new Hono();
// Enable CORS
app.use('*', cors({
origin: '*',
allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
allowHeaders: ['Content-Type', 'Authorization'],
exposeHeaders: ['Content-Length', 'X-Lucia-Username'], // Add X-Lucia-Username to exposed headers
maxAge: 600,
credentials: true,
const authMiddleware = new LuciaAuthMiddleware({
yawnxyz avatar
lucia_demo
@yawnxyz
@jsxImportSource npm:hono/jsx
HTTP (deprecated)
/** @jsxImportSource npm:hono/jsx **/
const userTable = "user";
const sessionTable = "session";
const adapter = new ValTownAdapter({ userTable, sessionTable });
export const lucia = new Lucia(adapter, {
getUserAttributes: (attributes) => {
return {
username: attributes.username,
declare module "npm:lucia" {
interface Register {
tionis avatar
lastlogin_demo
@tionis
HTTP (deprecated)
![Screenshot 2024-08-08 at 08.48.41.gif](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/7442086d-36b2-454d-bd5f-3c28615e900
/** @jsxImportSource npm:hono@3/jsx */
const app = new Hono();
app.get("/", (c) => {
const email = c.req.header("X-LastLogin-Email");
if (email) {
return c.html(
<div>
<h1>Welcome, {email}!</h1>
<a href="/auth/logout">Logout</a>
stevekrouse avatar
_
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import lodash from "npm:lodash";
export const _ = lodash;
yawnxyz avatar
htmxCounterExample
@yawnxyz
An interactive, runnable TypeScript val by yawnxyz
HTTP (deprecated)
/** @jsx jsx **/
/** @jsx jsx */
const app = new Hono();
const Layout = ({ children, title = "Counter Example" }) => (
<html lang="en">
<head>
<title>{title}</title>
<script src="https://unpkg.com/htmx.org@1.9.9"></script>
</head>
<body>
nbbaier avatar
cyanOrangutan
@nbbaier
An interactive, runnable TypeScript val by nbbaier
Script
import { PGlite } from "import { PGlite } from "npm:@electric-sql/pglite"";
const db = new PGlite()
await db.query("select 'Hello world' as message;")
neverstew avatar
ivoryPorpoise
@neverstew
@jsxImportSource https://esm.sh/preact
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/preact */
const appHTML = () => {
const now = new Date().toLocaleTimeString();
return (
<html lang="en">
<head>
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
<link rel="manifest" href="/manifest.json" />
pomdtr avatar
apricotPartridge
@pomdtr
// use my private proxy
HTTP (deprecated)
import { setEnv } from "https://esm.town/v/pomdtr/setEnv";
// use my private proxy
setEnv("VALTOWN_API_URL", "https://pomdtr-tursoproxy.web.val.run");
// need to be dynamic
const { handler } = await import("https://esm.town/v/nbbaier/sqliteExplorerApp");
export default handler;
stevekrouse avatar
importSSSS
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export const importSSSS = (async () => {
const { default: _ } = await import("npm:lodash");
return _.groupBy([{ a: 1 }, { a: 2 }], "a");
janpaul123 avatar
valleCodemirror
@janpaul123
// const ret = await build({
Script
// const ret = await build({
// dependencies: {
// "@codemirror/view": "^6",
// "@codemirror/autocomplete": "^6",
// "@codemirror/lang-javascript": "^6",
// "@codemirror/lint": "^6",
// "@codemirror/state": "^6",
// "@typescript/vfs": "^1.5.0",
// "codemirror": "^6",
// "typescript": "^5.2.2",
tmcw avatar
lodashExample
@tmcw
lodash Lodash is the most popular npm module. It provides helpers for functional programming, common algorithms, and a lot more. Before JavaScript had built-in methods for Array.map , lodash (and underscore before it) provided those methods.
Script
# lodash
[Lodash](https://lodash.com/) is the most popular npm module. It provides helpers for functional programming, common algorith
export let lodashExample = (async () => {
const _ = await import("npm:lodash-es");
return _.min([1, 2, 3]);
pfeffunit avatar
iangac_validator
@pfeffunit
IANGAC JSON validator
HTTP (deprecated)
# IANGAC JSON validator
/** @jsxImportSource npm:hono@3/jsx */
const app = new Hono();
function analyzeJSON(jsonData) {
const images = jsonData.images;
const allIds = new Set(images.map(img => img.id));
const referencedIds = new Set();
const errors = [];
const warnings = [];
// Check all references and track referenced IDs
tfayyaz avatar
whiteMongoose
@tfayyaz
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
export default async function(req: Request) {
return new Response(
renderToString(
<html>
<head>
<meta charSet="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tahir's TIL</title>
</head>
jahabeebs avatar
safeMessageBoard
@jahabeebs
content-checker is designed to be a modern, open-source library for programmatic and AI content moderation. Currently content-checker supports image and text moderation. Thanks to LLMs in addition to detecting specific profane words, we can detect malicious intent in text. So, a user who tries to circumvent the AI profanity filter by using a variation of a profane word, or even just a malicious phrase without a specific word in the profanity list, will still be flagged. Image moderation is also supported, using the Inception V3 model of the NSFW JS library. Future features will include moderation tools (auto-ban, bots), more powerful models, and multimedia support for video and audio moderation. To get an API key for the AI endpoints sign up free at https://www.openmoderator.com To install content-checker do npm install content-checker and check out the README: https://github.com/utilityfueled/content-checker
HTTP (deprecated)
`content-checker` is designed to be a modern, open-source library for programmatic and AI content moderation. Currently conte
Thanks to LLMs in addition to detecting specific profane words, we can detect malicious **intent** in text.
So, a user who tries to circumvent the AI profanity filter by using a variation of a profane word, or even just a malicious p
without a specific word in the profanity list, will still be flagged. Image moderation is also supported, using the Inception
Future features will include moderation tools (auto-ban, bots), more powerful models, and multimedia support for video and au
To get an API key for the AI endpoints sign up free at https://www.openmoderator.com
/** @jsxImportSource npm:hono@3/jsx */
const app = new Hono();
const apiKey = Deno.env.get("OPEN_MODERATOR_API_KEY");
if (!apiKey) {
…
12
…
Next