Back

Version 7

12/8/2024
import { Hono } from "npm:hono@3.2.7";
import _ from "npm:lodash";
// https://gist.github.com/maxmcd/b170e57d53cb942642c35b135e2d52f1 (takes a bit of time to load)
import { searchEmojis } from "https://esm.town/v/maxm/emojiVectorEmbeddings";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo?v=29";
const app = new Hono();

const { htmlUrl } = extractValInfo(import.meta.url);

const fuseOptions = {
// Only search for prefixes to make things faster
location: 0,
threshold: 0,
distance: 0,
};

// Search endpoint
app.get("/search", async (c) => {
let query = c.req.query("q");
if (typeof query !== "string") {
return c.text("Invalid query", 400);
}
query = query.trim();
const t0 = performance.now();
const results = await searchEmojis(query);
return c.json(results, 200, { "Time": String(performance.now() - t0) });
});

// Serve the frontend
app.get("/", (c) => {
return c.html(html);
});

const html = `
<!DOCTYPE html>
<html lang="en">
maxm-actuallygoodemojisearch.web.val.run
Updated: January 27, 2025