feat: implement SEO improvements, listing profiles, service images, and towns serviced
This commit is contained in:
32
src/listing/sitemap.rs
Normal file
32
src/listing/sitemap.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use axum::{
|
||||
extract::State,
|
||||
http::StatusCode,
|
||||
Json,
|
||||
};
|
||||
use crate::auth::structs::AppState;
|
||||
use serde::Serialize;
|
||||
use serde_json::json;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct ListingId {
|
||||
pub id: i32,
|
||||
pub company_name: String,
|
||||
}
|
||||
|
||||
pub async fn get_all_active_listing_ids(
|
||||
State(app_state): State<AppState>,
|
||||
) -> Result<Json<Vec<ListingId>>, (StatusCode, Json<serde_json::Value>)> {
|
||||
match sqlx::query_as!(
|
||||
ListingId,
|
||||
"SELECT id, company_name FROM listings WHERE is_active = true ORDER BY id DESC"
|
||||
)
|
||||
.fetch_all(&*app_state.db)
|
||||
.await
|
||||
{
|
||||
Ok(ids) => Ok(Json(ids)),
|
||||
Err(e) => Err((
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(json!({"error": format!("Failed to fetch listing ids: {}", e)}))
|
||||
)),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user