Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/%22mailto:kurt@sachersolutions.ca/%22https:/console.groq.com/keys//%22data:image/svg+xml,%3Csvg?q=api&page=1&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=api

Returns an array of strings in format "username" or "username/projectName"

Found 25518 results for "api"(1605ms)

untitled-1522api.ts16 matches

@jessicaocean•Updated 50 mins ago
29} from "../database/queries.ts";
30
31const api = new Hono();
32const openai = new OpenAI();
33
34// Middleware to ensure user is authenticated
35api.use('*', async (c, next) => {
36 const email = c.req.header('X-LastLogin-Email');
37 if (!email) {
47
48// Get user's conversations
49api.get('/conversations', async (c) => {
50 const user = c.get('user');
51 const conversations = await getUserConversationsWithParticipants(user.id);
54
55// Debug endpoint to check user status in a conversation
56api.get('/conversations/:id/status', async (c) => {
57 const user = c.get('user');
58 const conversationId = parseInt(c.req.param('id'));
78
79// Get specific conversation with messages
80api.get('/conversations/:id', async (c) => {
81 const user = c.get('user');
82 const conversationId = parseInt(c.req.param('id'));
99
100// Create new conversation
101api.post('/conversations', async (c) => {
102 const user = c.get('user');
103 const { title } = await c.req.json();
112
113// Delete conversation
114api.delete('/conversations/:id', async (c) => {
115 const user = c.get('user');
116 const conversationId = parseInt(c.req.param('id'));
130
131// Get conversation participants
132api.get('/conversations/:id/participants', async (c) => {
133 const user = c.get('user');
134 const conversationId = parseInt(c.req.param('id'));
152
153// Invite user to conversation
154api.post('/conversations/:id/invite', async (c) => {
155 const user = c.get('user');
156 const conversationId = parseInt(c.req.param('id'));
194
195 // Send invitation email
196 const inviteUrl = `${c.req.url.split('/api')[0]}/invite/${invite.invite_token}`;
197
198 try {
218
219// Remove participant from conversation
220api.delete('/conversations/:id/participants/:userId', async (c) => {
221 const user = c.get('user');
222 const conversationId = parseInt(c.req.param('id'));
248
249// Send chat message
250api.post('/chat', async (c) => {
251 const user = c.get('user');
252 const { message, conversationId }: ChatRequest = await c.req.json();
326
327// Get invite details (public endpoint)
328api.get('/invites/:token', async (c) => {
329 const token = c.req.param('token');
330
348
349// Accept invitation
350api.post('/invites/:token/accept', async (c) => {
351 const user = c.get('user');
352 const token = c.req.param('token');
381
382// Server-Sent Events for real-time updates
383api.get('/conversations/:id/stream', async (c) => {
384 const user = c.get('user');
385 const conversationId = parseInt(c.req.param('id'));
437});
438
439export default api;

untitled-1522README.md16 matches

@jessicaocean•Updated 54 mins ago
1# Backend
2
3Hono-based API server with LastLogin authentication, SQLite database, and group chat functionality.
4
5## Structure
7- `index.ts` - Main HTTP handler with LastLogin wrapper
8- `database/` - Database migrations and query functions
9- `routes/` - API route handlers
10
11## API Endpoints
12
13### Authentication
14- All API routes require authentication via LastLogin
15- User email is extracted from `X-LastLogin-Email` header
16
17### Conversations
18- `GET /api/conversations` - Get user's conversations (with participant info)
19- `GET /api/conversations/:id` - Get specific conversation with messages
20- `POST /api/conversations` - Create new conversation
21- `DELETE /api/conversations/:id` - Delete conversation (admin only)
22
23### Group Chat Features
24- `GET /api/conversations/:id/participants` - Get conversation participants
25- `POST /api/conversations/:id/invite` - Invite user by email (admin only)
26- `DELETE /api/conversations/:id/participants/:userId` - Remove participant (admin only)
27
28### Invitations
29- `GET /api/invites/:token` - Get invitation details (public)
30- `POST /api/invites/:token/accept` - Accept invitation and join conversation
31
32### Chat & Real-time
33- `POST /api/chat` - Send message and get ChatGPT response
34- `GET /api/conversations/:id/stream` - Server-Sent Events for real-time updates
35
36## Database Schema
49- **Automatic user creation** on first login
50- **Conversation history storage** with full message history
51- **ChatGPT integration** via OpenAI API
52- **Group chat functionality** with role-based permissions
53- **Email invitations** with secure tokens

untitled-1522README.md1 match

@jessicaocean•Updated 54 mins ago
31## Project Structure
32
33- `backend/` - Hono API server with authentication and group chat
34- `frontend/` - React chat interface with group features
35- `shared/` - Shared TypeScript types

untitled-1522App.tsx5 matches

@jessicaocean•Updated 54 mins ago
48 setIsLoadingConversations(true);
49 try {
50 const response = await fetch('/api/conversations');
51 if (response.ok) {
52 const data = await response.json();
63 setIsLoadingConversation(true);
64 try {
65 const response = await fetch(`/api/conversations/${id}`);
66 if (response.ok) {
67 const data = await response.json();
77 const loadConversationParticipants = async (conversationId: number) => {
78 try {
79 const response = await fetch(`/api/conversations/${conversationId}/participants`);
80 if (response.ok) {
81 const participants = await response.json();
105
106 try {
107 const response = await fetch(`/api/conversations/${id}`, {
108 method: 'DELETE'
109 });
131
132 try {
133 const response = await fetch('/api/chat', {
134 method: 'POST',
135 headers: {

untitled-1522ParticipantsList.tsx2 matches

@jessicaocean•Updated 56 mins ago
25 const loadParticipants = async () => {
26 try {
27 const response = await fetch(`/api/conversations/${conversationId}/participants`);
28 if (response.ok) {
29 const data = await response.json();
43
44 try {
45 const response = await fetch(`/api/conversations/${conversationId}/participants/${userId}`, {
46 method: 'DELETE'
47 });

untitled-1522InvitePage.tsx2 matches

@jessicaocean•Updated 57 mins ago
23 const loadInviteDetails = async () => {
24 try {
25 const response = await fetch(`/api/invites/${token}`);
26
27 if (!response.ok) {
45
46 try {
47 const response = await fetch(`/api/invites/${token}/accept`, {
48 method: 'POST'
49 });

untitled-1522InviteModal.tsx1 match

@jessicaocean•Updated 57 mins ago
32 const inviteRequest: InviteRequest = { email: email.trim() };
33
34 const response = await fetch(`/api/conversations/${conversationId}/invite`, {
35 method: 'POST',
36 headers: {

untitled-1522index.ts3 matches

@jessicaocean•Updated 58 mins ago
3import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import { runMigrations } from "./database/migrations.ts";
5import api from "./routes/api.ts";
6
7const app = new Hono();
13await runMigrations();
14
15// Mount API routes
16app.route('/api', api);
17
18// Serve static files

NotesREADME.md1 match

@json•Updated 1 hour ago
8- [theme](https://github.com/vadimdemedes/thememirror/tree/main/source/themes)
9
10## API
11
12You can access the code using the `code` property:

krazyy-cam-configmain.ts7 matches

@krazyykrunal•Updated 2 hours ago
35 JSON.stringify({
36 iss: serviceAccount.client_email,
37 scope: "https://www.googleapis.com/auth/datastore",
38 aud: "https://oauth2.googleapis.com/token",
39 exp: now + 3600,
40 iat: now,
71
72 // ---- Exchange JWT for access token ----
73 const tokenRes = await fetch("https://oauth2.googleapis.com/token", {
74 method: "POST",
75 headers: { "Content-Type": "application/x-www-form-urlencoded" },
90 // ---- Query Firestore publicLenses ----
91 const pubDocRes = await fetch(
92 `https://firestore.googleapis.com/v1/projects/${projectId}/databases/(default)/documents/publicLenses/${id}`,
93 { headers: { Authorization: `Bearer ${access_token}` } },
94 );
106 // ---- Query Firestore private user doc ----
107 const privDocRes = await fetch(
108 `https://firestore.googleapis.com/v1/projects/${projectId}/databases/(default)/documents/users/${owner}/lenses/${id}`,
109 { headers: { Authorization: `Bearer ${access_token}` } },
110 );
116 }
117 const privDoc = await privDocRes.json();
118 const apiToken = privDoc.fields.apiToken.stringValue;
119
120 // ---- Success ----
121 return new Response(JSON.stringify({ apiToken, groupId, lensId }), {
122 headers: corsHeaders(),
123 });

PixelPixelApiMonitor1 file match

@selfire1•Updated 20 hours ago
Regularly polls the API and messages on an error.

weatherApp1 file match

@dcm31•Updated 1 day ago
A simple weather app with dropdown cities using Open-Meteo API
fapian
<("<) <(")> (>")>
Kapil01