8
91. Sign up for [Cerebras](https://cloud.cerebras.ai/)
102. Get a Cerebras API Key
113. Save it in your project env variable called `CEREBRAS_API_KEY`
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>CerebrasCoder</title>
7 <link rel="preconnect" href="https://fonts.googleapis.com" />
8 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9 <link
10 href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
11 rel="stylesheet"
12 />
21 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
22 <meta property="og:type" content="website">
23 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
24
25
211 } catch (error) {
212 Toastify({
213 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
214 position: "center",
215 duration: 3000,
16 };
17 } else {
18 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
19 const completion = await client.chat.completions.create({
20 messages: [
13 <meta property="og:title" content="I proposed to my girlfriend in Quordle" />
14 <meta property="og:url" content="I proposed to my girlfriend in Quordle" />
15 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/emilrdle1.png" />
16 <meta property="twitter:title" content="I proposed to my girlfriend in Quordle" />
17 <meta property="og:type" content="article" />
19 <meta property="twitter:description" content="I proposed to my girlfriend in Quordle" />
20 <meta name="twitter:card" content="summary_large_image" />
21 <meta name="twitter:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/emilrdle1.png" />
22 <meta property="og:url" content="https://stevekrouse.com/proposal" />
23 <link rel="canonical" content="https://stevekrouse.com/proposal" />
56 screenshot of Quordle.
57 </p>
58 <img src="https://stevekrouse-blob_admin.web.val.run/api/public/emilrdle1.png" />
59 <p>
60 On a cold December night at Betaworks in Chelsea, I cozied up and worked with Townie for 90 minutes. It
124 <img
125 style={{ maxHeight: "500px", width: "auto", display: "block", margin: "0 auto" }}
126 src="https://stevekrouse-blob_admin.web.val.run/api/public/emilIMG_3220.JPG"
127 />
128 <p>
83 <li className="pb-2 sm:pb-1">
84 <span className={dateClass}>2013 Jun -</span>Software Engineer @{" "}
85 <Link href="http://firstround.com/">First Round Capital</Link>
86 </li>
87 <li className="pb-2 sm:pb-1">
1import { createRoute, z } from "https://esm.sh/@hono/zod-openapi@0.18.4";
2import { SearchResponseSchema } from "../../schemas.ts";
3import { authMiddleware } from "../auth.ts";
16 // NOTE: You can add middleware here or when the route is mounted,
17 // here we just need to use `as const` to ensure TypeScript infers the middleware's Context.
18 // see: https://github.com/honojs/middleware/tree/main/packages/zod-openapi#configure-middleware-for-each-endpoint
19 middleware: [authMiddleware] as const,
20 request: {
21 query: z.object({
22 query: z.string().openapi({ example: "valtown" }),
23 }),
24 },
37 // TODO: explicitly type what a 401 looks like
38 // schema: ErrorSchema,
39 schema: z.string().openapi({ example: "Unauthorized - Missing or invalid Bearer token" }),
40 },
41 },
47 // TODO: explicitly type what a 429 looks like
48 // schema: ErrorSchema,
49 schema: z.string().openapi({ example: "Rate limit exceeded" }),
50 },
51 },
1import { createFiberplane } from "https://esm.sh/@fiberplane/hono@0.4.4";
2import { OpenAPIHono } from "https://esm.sh/@hono/zod-openapi@0.18.4";
3import { HTTPException } from "https://esm.sh/hono@4.7.0/http-exception";
4import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
19const SOCIAL_DATA_COST_PER_TWEET = 0.0002;
20
21const app = new OpenAPIHono();
22
23app.openAPIRegistry.registerComponent("securitySchemes", "Bearer", {
24 type: "http",
25 scheme: "bearer",
26});
27
28app.openapi(searchTwitterRoute, async c => {
29 const { query } = c.req.valid("query");
30 const bearerToken = c.get("bearerToken");
67});
68
69// Create OpenAPI documentation
70app.doc("/openapi.json", {
71 openapi: "3.0.0",
72 info: {
73 title: "User Management API",
74 version: "v1.0.0",
75 },
76});
77
78// Mount the Fiberplane UI at the root to be able to test api endpoints
79app.use(
80 "/*",
81 createFiberplane({
82 openapi: { url: "/openapi.json" },
83 }),
84);
2
3/**
4 * Authentication middleware that validates the valtown api key as a bearer token,
5 * while maintaining backwards compatibility with old proxy
6 *
22 <meta name="viewport" content="width=device-width, initial-scale=1.0">
23 <title>DevStats Dashboard</title>
24 <link rel="preconnect" href="https://fonts.googleapis.com">
25 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
26 <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap" rel="stylesheet">
27 <script src="https://cdn.tailwindcss.com"></script>
28 <script src="https://esm.town/v/std/catch"></script>
126type Rows = Awaited<ReturnType<typeof getRows>>;
127
128app.get("/api", async function apiRoute(c) {
129 try {
130 return c.json(await getRows());