38.catch(console.error);
3940// API routes
4142// Auth routes
43app.post("/api/auth/login", async (c) => {
44const body = await c.req.json();
45const { email, password } = body;
58});
5960app.post("/api/auth/register", async (c) => {
61const body = await c.req.json();
62const { name, email, password } = body;
75});
7677app.get("/api/auth/me", authenticate, async (c) => {
78const user = c.get("user");
79return c.json({ success: true, data: user });
8182// Property routes
83app.get("/api/properties", async (c) => {
84const page = parseInt(c.req.query("page") || "1");
85const limit = parseInt(c.req.query("limit") || "10");
109});
110111app.get("/api/properties/featured", async (c) => {
112const limit = parseInt(c.req.query("limit") || "6");
113
121});
122123app.get("/api/properties/:id", async (c) => {
124const id = parseInt(c.req.param("id"));
125
137});
138139app.post("/api/properties", authenticate, agentOrAdmin, async (c) => {
140const user = c.get("user");
141const body = await c.req.json();
155});
156157app.put("/api/properties/:id", authenticate, agentOrAdmin, async (c) => {
158const id = parseInt(c.req.param("id"));
159const user = c.get("user");
180});
181182app.delete("/api/properties/:id", authenticate, agentOrAdmin, async (c) => {
183const id = parseInt(c.req.param("id"));
184const user = c.get("user");
205206// User routes
207app.get("/api/users", authenticate, adminOnly, async (c) => {
208try {
209const users = await userController.getAllUsers();
215});
216217app.get("/api/users/agents", async (c) => {
218try {
219const agents = await userController.getAgents();
225});
226227app.get("/api/users/:id", authenticate, async (c) => {
228const id = parseInt(c.req.param("id"));
229const user = c.get("user");
247});
248249app.put("/api/users/:id", authenticate, async (c) => {
250const id = parseInt(c.req.param("id"));
251const user = c.get("user");
272});
273274app.post("/api/users/:id/change-password", authenticate, async (c) => {
275const id = parseInt(c.req.param("id"));
276const user = c.get("user");
313});
314315app.delete("/api/users/:id", authenticate, adminOnly, async (c) => {
316const id = parseInt(c.req.param("id"));
317
335336// Inquiry routes
337app.post("/api/inquiries", async (c) => {
338const body = await c.req.json();
339const { propertyId, name, email, message, phone } = body;
379});
380381app.get("/api/inquiries", authenticate, agentOrAdmin, async (c) => {
382const user = c.get("user");
383const page = parseInt(c.req.query("page") || "1");
395});
396397app.get("/api/inquiries/my", authenticate, async (c) => {
398const user = c.get("user");
399
407});
408409app.get("/api/inquiries/:id", authenticate, agentOrAdmin, async (c) => {
410const id = parseInt(c.req.param("id"));
411
423});
424425app.put("/api/inquiries/:id/status", authenticate, agentOrAdmin, async (c) => {
426const id = parseInt(c.req.param("id"));
427const user = c.get("user");
453});
454455app.delete("/api/inquiries/:id", authenticate, agentOrAdmin, async (c) => {
456const id = parseInt(c.req.param("id"));
457const user = c.get("user");
478479// Favorite routes
480app.post("/api/favorites/:propertyId", authenticate, async (c) => {
481const propertyId = parseInt(c.req.param("propertyId"));
482const user = c.get("user");
500});
501502app.delete("/api/favorites/:propertyId", authenticate, async (c) => {
503const propertyId = parseInt(c.req.param("propertyId"));
504const user = c.get("user");
522});
523524app.get("/api/favorites", authenticate, async (c) => {
525const user = c.get("user");
526
534});
535536app.get("/api/favorites/check/:propertyId", authenticate, async (c) => {
537const propertyId = parseInt(c.req.param("propertyId"));
538const user = c.get("user");
552553// Dashboard routes
554app.get("/api/dashboard", authenticate, agentOrAdmin, async (c) => {
555const user = c.get("user");
556
untitled-3483README.md6 matches
5## Structure
67- `index.ts` - Main entry point and API routes using Hono framework
8- `database/` - Database setup, migrations, and queries
910## API Endpoints
1112- `GET /api/categories` - Get all product categories
13- `GET /api/products` - Get products with optional filtering
14- Query params: `featured`, `category`, `limit`, `search`
15- `GET /api/products/:slug` - Get a single product by slug
16- `GET /api/featured` - Get featured products
1718## Page Routes
untitled-3483index.ts8 matches
30const viewSourceUrl = projectInfo.links.self.project;
3132// API Routes
33const api = new Hono();
3435// Get all categories
36api.get("/categories", async (c) => {
37const categories = await getCategories();
38return c.json(categories);
4041// Get products with optional filtering
42api.get("/products", async (c) => {
43const { featured, category, limit, search } = c.req.query();
44
6768// Get a single product by slug
69api.get("/products/:slug", async (c) => {
70const slug = c.req.param("slug");
71const product = await getProductBySlug(slug);
7980// Get featured products
81api.get("/featured", async (c) => {
82const limit = c.req.query("limit");
83const products = await getFeaturedProducts(limit ? parseInt(limit) : 6);
85});
8687// Mount API routes
88app.route("/api", api);
8990// Serve static files
untitled-3483index.js1 match
700
701try {
702const response = await fetch(`/api/products?search=${encodeURIComponent(query)}`);
703const products = await response.json();
704
untitled-3483README.md1 match
14## Project Structure
1516- `backend/index.ts` - Main HTTP entry point and API routes
17- `backend/database/` - Database setup and queries
18- `frontend/` - All frontend assets (HTML, CSS, JS)
131}
132133// API Response types
134export interface ApiResponse<T> {
135success: boolean;
136data?: T;
1718- **Frontend**: React with TailwindCSS
19- **Backend**: Hono API framework on Val Town
20- **Database**: SQLite for data storage
21- **Authentication**: JWT-based authentication
71โ โ โโโ ...
72โ โโโ utils/
73โ โ โโโ api.ts
74โ โ โโโ helpers.ts
75โ โโโ index.html
21
22try {
23const response = await fetch(`/api/weather/${encodeURIComponent(location)}`);
24
25if (!response.ok) {
43const fetchRecentSearches = async () => {
44try {
45const response = await fetch("/api/history");
46if (response.ok) {
47const data = await response.json();
55const clearSearchHistory = async () => {
56try {
57const response = await fetch("/api/history", {
58method: "DELETE"
59});
102
103<footer className="mt-12 text-center text-white text-opacity-70 text-sm">
104<p>Data provided by Open-Meteo API</p>
105<p className="mt-1">
106<a
dddweather.ts4 matches
2import type { WeatherData, CurrentWeather, ForecastDay, Location } from "../shared/types.ts";
34// Geocoding API to get coordinates from location name
5export async function getCoordinates(locationName: string): Promise<Location | null> {
6try {
7const response = await fetch(
8`https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(locationName)}&count=1&language=en&format=json`
9);
10
28}
2930// Fetch current weather and forecast data from Open-Meteo API
31export async function getWeatherData(latitude: number, longitude: number): Promise<WeatherData | null> {
32try {
33const response = await fetch(
34`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t=temperature_2m,relative_humidity_2m,weather_code,wind_speed_10m,wind_direction_10m&daily=weather_code,temperature_2m_max,temperature_2m_min,sunrise,sunset,precipitation_sum&timezone=auto&forecast_days=4`
35);
36
CrazyTestValREADME.md3 matches
6- Serving HTML content
7- Client-side JavaScript
8- API integration
9- Basic UI with TailwindCSS
1016## Features
17181. **Current Time API**: Fetches the current server time from a backend API endpoint
192. **Click Counter**: Simple client-side counter with increment and reset functionality
203. **Responsive Design**: Mobile-friendly layout using TailwindCSS
22## How to Use
23241. Click the "Get Current Time" button to fetch the current server time from the API
252. Use the increment and reset buttons to manage the counter
263. View the source code by clicking the "View Source" link