untitled-7712index.ts7 matches
51});
5253// API Routes
54// Users
55app.post("/api/users", async c => {
56const { username } = await c.req.json();
57
70});
7172app.get("/api/users", async c => {
73const users = await getUsers();
74return c.json(users);
7677// Jobs
78app.get("/api/jobs", async c => {
79const jobs = await getJobs();
80return c.json(jobs);
81});
8283app.post("/api/jobs", async c => {
84const { title, company, description, location, contactEmail, postedBy } = await c.req.json();
85
101102// Chat messages
103app.get("/api/messages", async c => {
104const limit = c.req.query("limit") ? parseInt(c.req.query("limit") || "50") : 50;
105const messages = await getMessages(limit);
107});
108109app.post("/api/messages", async c => {
110const { content, username } = await c.req.json();
111
untitled-7712README.md8 matches
5## Structure
67- `index.ts` - Main entry point for the Hono API server
8- `database/` - Database setup and queries
9- `migrations.ts` - Database schema definitions
10- `queries.ts` - Database query functions
1112## API Endpoints
1314### Users
1516- `GET /api/users` - Get all users
17- `POST /api/users` - Create a new user
18- Body: `{ "username": "string" }`
1920### Jobs
2122- `GET /api/jobs` - Get all job listings
23- `POST /api/jobs` - Create a new job listing
24- Body:
25```json
36### Messages
3738- `GET /api/messages` - Get chat messages
39- Query params: `limit` (optional, default: 50)
40- `POST /api/messages` - Send a new chat message
41- Body: `{ "content": "string", "username": "string" }`
untitled-7712index.js6 matches
81}
8283// API calls
84async function fetchJobs() {
85try {
86const response = await fetch('/api/jobs');
87if (!response.ok) throw new Error('Failed to fetch jobs');
88
97async function fetchMessages(limit = 50) {
98try {
99const response = await fetch(`/api/messages?limit=${limit}`);
100if (!response.ok) throw new Error('Failed to fetch messages');
101
117async function createUser(username) {
118try {
119const response = await fetch('/api/users', {
120method: 'POST',
121headers: { 'Content-Type': 'application/json' },
136async function createJob(jobData) {
137try {
138const response = await fetch('/api/jobs', {
139method: 'POST',
140headers: { 'Content-Type': 'application/json' },
155async function sendMessage(content) {
156try {
157const response = await fetch('/api/messages', {
158method: 'POST',
159headers: { 'Content-Type': 'application/json' },
untitled-7712README.md1 match
15## Project Structure
1617- `/backend` - Hono API server and database logic
18- `/frontend` - HTML, CSS, and client-side JavaScript
19- `/shared` - Shared types and utilities
pass-genpassword-generator.ts3 matches
232}
233
234// Function to capitalize first letter
235function capitalize(word) {
236return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
237}
257
258// Format as Word99Word!
259const formattedPassword = \`\${capitalize(word1)}99\${capitalize(word2)}!\`;
260
261// Update the password field
67- Generates passwords using the format: Word99Word!
8- Sources random words from the dinopass.com API
9- Extracts whole words from the dinopass response
10- Capitalizes the first letter of each word
11- Modern UI with a copy-to-clipboard function
12- Responsive design that works on all devices
161. When the "Generate Password" button is clicked, the app fetches a simple password from dinopass.com
172. It extracts two whole words from the response
183. It formats them as Word99Word! (with capitalized first letters)
194. The password is displayed in the input field
205. Users can copy the password to clipboard with the copy button
2324- Built with vanilla JavaScript and Tailwind CSS
25- Uses the dinopass.com API to source random words
26- Implements a modern, accessible UI
27- Includes error handling for API failures
28- Provides visual feedback for copy operations
29
untitled-2444index.ts37 matches
132const startTime = Date.now();
133
134// Process the text - either via direct API or server proxy
135let result;
136let metadata = {
141};
142
143// Check if we're using direct API connection
144const apiKeyInput = document.getElementById("apiKey") as HTMLInputElement;
145if (apiKeyInput && apiKeyInput.value && localStorage.getItem("useDirectApi") === "true") {
146// Process directly with OpenAI API
147const prompt = createPromptForScriptType(
148text,
163} else {
164// Use the server proxy
165const response = await fetch("/api/process", {
166method: "POST",
167body: formData
319const temperatureSlider = document.getElementById("temperature") as HTMLInputElement;
320const temperatureValue = document.getElementById("temperatureValue") as HTMLSpanElement;
321const apiKeyInput = document.getElementById("apiKey") as HTMLInputElement;
322const useApiKeyBtn = document.getElementById("useApiKeyBtn") as HTMLButtonElement;
323const showDebugConsoleCheckbox = document.getElementById("showDebugConsole") as HTMLInputElement;
324const resetSettingsBtn = document.getElementById("resetSettingsBtn") as HTMLButtonElement;
325
326if (!advancedOptionsBtn || !advancedOptions || !temperatureSlider || !temperatureValue ||
327!apiKeyInput || !useApiKeyBtn || !showDebugConsoleCheckbox || !resetSettingsBtn) {
328console.error("Advanced options elements not found");
329return;
340});
341
342// Handle API key
343useApiKeyBtn.addEventListener("click", () => {
344const apiKey = apiKeyInput.value.trim();
345
346if (!apiKey) {
347alert("Please enter an API key");
348return;
349}
350
351if (!apiKey.startsWith("sk-")) {
352alert("Invalid API key format. OpenAI API keys start with 'sk-'");
353return;
354}
355
356try {
357// Set the API key in the connector
358openAIConnector.setApiKey(apiKey);
359
360// Store the preference (but not the key itself)
361localStorage.setItem("useDirectApi", "true");
362
363useApiKeyBtn.textContent = "✓ Using Key";
364useApiKeyBtn.classList.add("bg-green-50", "text-green-700", "border-green-300");
365useApiKeyBtn.classList.remove("bg-white", "text-gray-700", "border-gray-300");
366
367setTimeout(() => {
368useApiKeyBtn.textContent = "Use Key";
369useApiKeyBtn.classList.remove("bg-green-50", "text-green-700", "border-green-300");
370useApiKeyBtn.classList.add("bg-white", "text-gray-700", "border-gray-300");
371}, 2000);
372} catch (error) {
373alert(`Error setting API key: ${error instanceof Error ? error.message : "Unknown error"}`);
374}
375});
376
377// Check if we have a stored preference
378if (localStorage.getItem("useDirectApi") === "true") {
379apiKeyInput.placeholder = "API key will be used if provided";
380}
381
391// Reset settings
392resetSettingsBtn.addEventListener("click", () => {
393// Reset API key preference
394localStorage.removeItem("useDirectApi");
395apiKeyInput.value = "";
396apiKeyInput.placeholder = "sk-...";
397
398// Reset temperature
727
728try {
729const response = await fetch("/api/detect-type", {
730method: "POST",
731headers: {
757/**
758* Create a prompt based on script type
759* This is a duplicate of the server-side function to enable direct API calls
760*/
761function createPromptForScriptType(
1045readabilityTarget: (document.getElementById("readabilityTarget") as HTMLSelectElement)?.value,
1046toneAdjustment: (document.getElementById("toneAdjustment") as HTMLSelectElement)?.value,
1047useDirectApi: localStorage.getItem("useDirectApi") === "true",
1048timestamp: new Date().toISOString()
1049};
1117}
1118
1119if (settings.useDirectApi !== undefined) {
1120localStorage.setItem("useDirectApi", settings.useDirectApi.toString());
1121}
1122
440441function ProductCarousel({ children }: { children: React.ReactNode }) {
442const [emblaRef, emblaApi] = useEmblaCarousel({
443axis: "x",
444loop: false,
465466useEffect(() => {
467if (emblaApi) {
468scrollByRef.current = (delta: number) => {
469isScrollingRef.current = true;
470const scrollResult = emblaApi.scrollTo(emblaApi.selectedScrollSnap() + Math.sign(delta));
471472if (scrollResult && typeof scrollResult.then === "function") {
479};
480481const rootNode = emblaApi.rootNode();
482rootNode.addEventListener("wheel", onWheel, { passive: false });
483rootNode.style.overflowY = "auto";
488};
489}
490}, [emblaApi, onWheel]);
491492return (
690691const script = document.createElement("script");
692script.src = `https://maps.googleapis.com/maps/api/js?key=AIzaSyAOtUMb5jLTjTVM7iKzIx2SJ3HgMKNcM7U&libraries=places`;
693script.async = true;
694script.defer = true;
814// Reverse geocode the coordinates to get an address
815const response = await fetch(
816`https://maps.googleapis.com/maps/api/geocode/json?latlng=${position.coords.latitude},${position.coords.longitude}&key=AIzaSyAOtUMb5jLTjTVM7iKzIx2SJ3HgMKNcM7U`,
817);
818const data = await response.json();
1184});
11851186app.post("/api", async (c) => {
1187console.log(c.req.body);
1188return c.json({ ok: true });
2import { readFile, serveFile, parseProject } from "https://esm.town/v/std/utils@85-main/index.ts";
3import { runMigrations } from "./database/migrations.ts";
4import apiRoutes from "./routes/api.ts";
56// Initialize the app
38});
3940// API routes
41app.route("/api", apiRoutes);
4243// Serve static files
createContactDetail.tsx4 matches
30
31try {
32const response = await fetch(`/api/contacts/${contact.id}/interactions`);
33const result = await response.json();
34
54const handleAddInteraction = async (interaction: Interaction) => {
55try {
56const response = await fetch("/api/interactions", {
57method: "POST",
58headers: { "Content-Type": "application/json" },
83
84try {
85const response = await fetch(`/api/interactions/${id}`, {
86method: "DELETE"
87});
222<div>
223<div className="flex items-center">
224<span className="font-medium capitalize">
225{interaction.type}
226</span>