Freelancingusers.ts12 matches
2import { authMiddleware } from "./auth.ts";
3import { getUserById, updateUser, getFreelancers } from "../database/queries.ts";
4import type { ApiResponse, User } from "../../shared/types.ts";
56const users = new Hono();
12
13if (isNaN(id)) {
14return c.json<ApiResponse>({
15success: false,
16error: "Invalid user ID"
21
22if (!user) {
23return c.json<ApiResponse>({
24success: false,
25error: "User not found"
30const { password_hash: _, ...userResponse } = user;
3132return c.json<ApiResponse<User>>({
33success: true,
34data: userResponse
37} catch (error) {
38console.error("Get user error:", error);
39return c.json<ApiResponse>({
40success: false,
41error: "Failed to fetch user"
51
52if (isNaN(id)) {
53return c.json<ApiResponse>({
54success: false,
55error: "Invalid user ID"
59// Users can only update their own profile
60if (currentUser.userId !== id) {
61return c.json<ApiResponse>({
62success: false,
63error: "Unauthorized"
80
81if (!updatedUser) {
82return c.json<ApiResponse>({
83success: false,
84error: "User not found"
89const { password_hash: _, ...userResponse } = updatedUser;
9091return c.json<ApiResponse<User>>({
92success: true,
93data: userResponse
96} catch (error) {
97console.error("Update user error:", error);
98return c.json<ApiResponse>({
99success: false,
100error: "Failed to update user"
115});
116117return c.json<ApiResponse<User[]>>({
118success: true,
119data: freelancersResponse
122} catch (error) {
123console.error("Get freelancers error:", error);
124return c.json<ApiResponse>({
125success: false,
126error: "Failed to fetch freelancers"
Createajobpostingindex.ts2 matches
15await initializeDatabase();
1617// API routes
18app.route("/api/jobs", jobsRouter);
1920// Serve static files
Freelancingtypes.ts1 match
58}
5960export interface ApiResponse<T = any> {
61success: boolean;
62data?: T;
CreateajobpostingApp.tsx3 matches
39const fetchJobs = async (filter?: string) => {
40try {
41const url = filter && filter !== 'all' ? `/api/jobs?type=${filter}` : '/api/jobs';
42const response = await fetch(url);
43if (!response.ok) throw new Error('Failed to fetch jobs');
57
58try {
59const response = await fetch('/api/jobs', {
60method: 'POST',
61headers: {
82const handleDeleteJob = async (id: number) => {
83try {
84const response = await fetch(`/api/jobs/${id}`, {
85method: 'DELETE',
86});
FreelancingREADME.md12 matches
43## Tech Stack
4445- **Backend**: Hono (TypeScript API framework)
46- **Database**: SQLite with Val Town's sqlite service
47- **Frontend**: React 18.2.0 with TypeScript
574. Register as a freelancer or client to get started
5859## API Endpoints
6061- `GET /` - Main application
62- `POST /api/auth/register` - User registration
63- `POST /api/auth/login` - User login
64- `GET /api/jobs` - List jobs
65- `POST /api/jobs` - Create job posting
66- `GET /api/users/:id` - Get user profile
67- `PUT /api/users/:id` - Update user profile
68- `GET /api/chat/messages` - Get chat messages
69- `POST /api/chat/messages` - Send chat message
70- `GET /api/chat/stream` - SSE chat stream
7172## Environment Variables
7374No API keys required - uses Val Town's built-in services.
CreateajobpostingREADME.md5 matches
13## Structure
1415- `backend/` - Hono API server with job CRUD operations
16- `frontend/` - React-based job board interface
17- `shared/` - Shared TypeScript types and utilities
1819## API Endpoints
2021- `GET /` - Serve the main application
22- `GET /api/jobs` - Get all jobs (with optional type filter)
23- `POST /api/jobs` - Create a new job posting
24- `DELETE /api/jobs/:id` - Delete a job posting
2526## Usage
untitled-6759Umain.tsx2 matches
6// Get coordinates for the city
7const geoResponse = await fetch(
8`https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(city)}&count=1&language=en&format=json`,
9);
10const geoData = await geoResponse.json();
19// Get weather data
20const weatherResponse = await fetch(
21`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t=temperature_2m,relative_humidity_2m,apparent_temperature,weather_code,wind_speed_10m&daily=weather_code,temperature_2m_max,temperature_2m_min&timezone=auto&forecast_days=5`,
22);
23const weatherData = await weatherResponse.json();
templateTwitterAlertREADME.md4 matches
31Refer to [Twitter's search operators](https://socialdata.gitbook.io/docs/twitter-tweets/retrieve-search-results-by-keyword#endpoint-parameters) to fine-tune your query.
3233### 4. Test API call
34Set `isProd = false` in the code if you are testing, to ensure there are enough tweets to display. <br>
35Toggle it back to `true` when you're ready to run this cron job in production and actuall send notifications.
6061### NOTE: Usage Limits
62This val uses the SocialData API for Twitter data:
6364- **Proxies via Val Town's [SocialDataProxy](https://www.val.town/v/stevekrouse/socialDataProxy)**: Limited to 10 cents per day for [**Val Town Pro users**](https://www.val.town/pricing). This API is *only* for Pro users.
65- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.
untitled-5321README.md5 matches
13```
14โโโ backend/
15โ โโโ index.ts # Main Hono server with API routes
16โโโ frontend/
17โ โโโ components/
27```
2829## API Endpoints
3031- `GET /` - Serves the main application
32- `POST /api/chat` - Handles chat/question requests
33- `POST /api/generate-image` - Handles image generation requests
3435## Environment Variables
3637- `OPENAI_API_KEY` - Required for OpenAI API access (automatically configured in Val Town)
3839## Usage
untitled-5321index.ts5 matches
23});
2425// Chat API endpoint
26app.post("/api/chat", async c => {
27try {
28const body: ChatRequest = await c.req.json();
7879} catch (error) {
80console.error("Chat API error:", error);
81return c.json<ChatResponse>({
82message: "",
87});
8889// Image generation API endpoint
90app.post("/api/generate-image", async c => {
91try {
92const body: ImageGenerationRequest = await c.req.json();