Freelancingjobs.ts30 matches
9getJobApplications
10} from "../database/queries.ts";
11import type { ApiResponse, Job, JobApplication } from "../../shared/types.ts";
1213const jobs = new Hono();
24const jobsList = await getJobs(filters);
2526return c.json<ApiResponse<Job[]>>({
27success: true,
28data: jobsList
31} catch (error) {
32console.error("Get jobs error:", error);
33return c.json<ApiResponse>({
34success: false,
35error: "Failed to fetch jobs"
44
45if (isNaN(id)) {
46return c.json<ApiResponse>({
47success: false,
48error: "Invalid job ID"
53
54if (!job) {
55return c.json<ApiResponse>({
56success: false,
57error: "Job not found"
59}
6061return c.json<ApiResponse<Job>>({
62success: true,
63data: job
66} catch (error) {
67console.error("Get job error:", error);
68return c.json<ApiResponse>({
69success: false,
70error: "Failed to fetch job"
8283if (!title || !description || !budget_type || !skills_required) {
84return c.json<ApiResponse>({
85success: false,
86error: "Missing required fields"
8990if (!['fixed', 'hourly'].includes(budget_type)) {
91return c.json<ApiResponse>({
92success: false,
93error: "Invalid budget type"
103}
104} catch (e) {
105return c.json<ApiResponse>({
106success: false,
107error: "Skills required must be a valid array"
120});
121122return c.json<ApiResponse<Job>>({
123success: true,
124data: job
127} catch (error) {
128console.error("Create job error:", error);
129return c.json<ApiResponse>({
130success: false,
131error: "Failed to create job"
141
142if (isNaN(id)) {
143return c.json<ApiResponse>({
144success: false,
145error: "Invalid job ID"
149const job = await getJobById(id);
150if (!job) {
151return c.json<ApiResponse>({
152success: false,
153error: "Job not found"
157// Only job owner can update
158if (job.client_id !== currentUser.userId) {
159return c.json<ApiResponse>({
160success: false,
161error: "Unauthorized"
176updates.skills_required = JSON.stringify(skillsArray);
177} catch (e) {
178return c.json<ApiResponse>({
179success: false,
180error: "Skills required must be a valid array"
185const updatedJob = await updateJob(id, updates);
186187return c.json<ApiResponse<Job>>({
188success: true,
189data: updatedJob
192} catch (error) {
193console.error("Update job error:", error);
194return c.json<ApiResponse>({
195success: false,
196error: "Failed to update job"
206
207if (isNaN(jobId)) {
208return c.json<ApiResponse>({
209success: false,
210error: "Invalid job ID"
214const job = await getJobById(jobId);
215if (!job) {
216return c.json<ApiResponse>({
217success: false,
218error: "Job not found"
221222if (job.status !== 'open') {
223return c.json<ApiResponse>({
224success: false,
225error: "Job is not open for applications"
230231if (!proposal) {
232return c.json<ApiResponse>({
233success: false,
234error: "Proposal is required"
243});
244245return c.json<ApiResponse<JobApplication>>({
246success: true,
247data: application
251console.error("Apply to job error:", error);
252if (error.message?.includes("UNIQUE constraint failed")) {
253return c.json<ApiResponse>({
254success: false,
255error: "You have already applied to this job"
256}, 409);
257}
258return c.json<ApiResponse>({
259success: false,
260error: "Failed to apply to job"
270
271if (isNaN(jobId)) {
272return c.json<ApiResponse>({
273success: false,
274error: "Invalid job ID"
278const job = await getJobById(jobId);
279if (!job) {
280return c.json<ApiResponse>({
281success: false,
282error: "Job not found"
286// Only job owner can view applications
287if (job.client_id !== currentUser.userId) {
288return c.json<ApiResponse>({
289success: false,
290error: "Unauthorized"
294const applications = await getJobApplications(jobId);
295296return c.json<ApiResponse<JobApplication[]>>({
297success: true,
298data: applications
301} catch (error) {
302console.error("Get job applications error:", error);
303return c.json<ApiResponse>({
304success: false,
305error: "Failed to fetch applications"
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