cerebras_coderindex.html3 matches
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
10href="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"
11rel="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
16};
17} else {
18const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
19const completion = await client.chat.completions.create({
20messages: [
2import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
3import { runMigrations } from "./database/migrations.ts";
4import api from "./routes/api.ts";
56const app = new Hono();
14await runMigrations();
1516// API routes
17app.route('/api', api);
1819// Serve static files
3import type { PurchaseRequest, PurchaseResponse } from "../../shared/types.ts";
45const api = new Hono();
67// Get all products
8api.get('/products', async (c) => {
9try {
10const products = await getAllProducts();
1718// Purchase a product
19api.post('/purchase', async (c) => {
20try {
21const body: PurchaseRequest = await c.req.json();
58});
5960export default api;
1819try {
20const response = await fetch('/api/products');
21if (!response.ok) {
22throw new Error(`HTTP error! status: ${response.status}`);
7374try {
75const response = await fetch('/api/purchase', {
76method: 'POST',
77headers: {
12## Structure
1314- `backend/index.ts` - Main Hono server with API routes
15- `backend/database/` - Database setup and queries
16- `frontend/` - HTML, CSS, and JavaScript for the website
19## Usage
2021The main entry point is `backend/index.ts` which serves both the API and static files.
untitled-3477dailyFactTweet.ts17 matches
4*
5* Required Environment Variables:
6* - TWITTER_API_KEY: Your Twitter API key
7* - TWITTER_API_SECRET: Your Twitter API secret
8* - TWITTER_ACCESS_TOKEN: Your Twitter access token
9* - TWITTER_ACCESS_TOKEN_SECRET: Your Twitter access token secret
1112interface TwitterCredentials {
13apiKey: string;
14apiSecret: string;
15accessToken: string;
16accessTokenSecret: string;
4748/**
49* Generate OAuth 1.0a signature for Twitter API
50*/
51async function generateTwitterSignature(
57// OAuth 1.0a signature generation
58const oauthParams = {
59oauth_consumer_key: credentials.apiKey,
60oauth_token: credentials.accessToken,
61oauth_signature_method: 'HMAC-SHA1',
7879// Create signing key
80const signingKey = `${encodeURIComponent(credentials.apiSecret)}&${encodeURIComponent(credentials.accessTokenSecret)}`;
8182// Generate signature using HMAC-SHA1
100101/**
102* Post a tweet to Twitter using the v1.1 API
103*/
104async function postTweet(text: string, credentials: TwitterCredentials): Promise<boolean> {
105const url = 'https://api.twitter.com/1.1/statuses/update.json';
106const method = 'POST';
107const params = { status: text };
111
112const oauthHeader = [
113`oauth_consumer_key="${encodeURIComponent(credentials.apiKey)}"`,
114`oauth_token="${encodeURIComponent(credentials.accessToken)}"`,
115`oauth_signature_method="HMAC-SHA1"`,
131if (!response.ok) {
132const errorText = await response.text();
133console.error('Twitter API Error:', response.status, errorText);
134return false;
135}
160// Get Twitter credentials from environment variables
161const credentials: TwitterCredentials = {
162apiKey: Deno.env.get('TWITTER_API_KEY') || '',
163apiSecret: Deno.env.get('TWITTER_API_SECRET') || '',
164accessToken: Deno.env.get('TWITTER_ACCESS_TOKEN') || '',
165accessTokenSecret: Deno.env.get('TWITTER_ACCESS_TOKEN_SECRET') || ''
167168// Validate credentials
169if (!credentials.apiKey || !credentials.apiSecret || !credentials.accessToken || !credentials.accessTokenSecret) {
170console.error('❌ Missing Twitter API credentials. Please set the following environment variables:');
171console.error('- TWITTER_API_KEY');
172console.error('- TWITTER_API_SECRET');
173console.error('- TWITTER_ACCESS_TOKEN');
174console.error('- TWITTER_ACCESS_TOKEN_SECRET');
HN-fetch-callmain.tsx1 match
1import { fetchItem, fetchMaxItemId } from "./api.tsx";
23export async function main(req: Request) {
16await runMigrations();
1718// API routes
19app.route("/api/auth", auth);
20app.route("/api/bills", bills);
21app.route("/api/payments", payments);
2223// Static file serving and main page
blob_adminmain.tsx6 matches
1415// Public route without authentication
16app.get("/api/public/:id", async (c) => {
17const key = `__public/${c.req.param("id")}`;
18const { blob } = await import("https://esm.town/v/std/blob");
132};
133134app.get("/api/blobs", checkAuth, async (c) => {
135const prefix = c.req.query("prefix") || "";
136const limit = parseInt(c.req.query("limit") || "20", 10);
141});
142143app.get("/api/blob", checkAuth, async (c) => {
144const key = c.req.query("key");
145if (!key) return c.text("Missing key parameter", 400);
149});
150151app.put("/api/blob", checkAuth, async (c) => {
152const key = c.req.query("key");
153if (!key) return c.text("Missing key parameter", 400);
158});
159160app.delete("/api/blob", checkAuth, async (c) => {
161const key = c.req.query("key");
162if (!key) return c.text("Missing key parameter", 400);
166});
167168app.post("/api/blob", checkAuth, async (c) => {
169const { file, key } = await c.req.parseBody();
170if (!file || !key) return c.text("Missing file or key", 400);