A decentralized music tracking and discovery platform built on AT Protocol 🎵

[api] add cors middleware to xrpc server

+13 -2
+1
apps/api/package.json
··· 44 44 "better-sqlite3": "^11.8.1", 45 45 "chalk": "^5.4.1", 46 46 "chanfana": "^2.0.2", 47 + "cors": "^2.8.5", 47 48 "dayjs": "^1.11.13", 48 49 "dotenv": "^16.4.7", 49 50 "drizzle-orm": "^0.44.2",
+2
apps/api/src/server.ts
··· 1 1 import { ctx } from "context"; 2 + import cors from "cors"; 2 3 import express from "express"; 3 4 import { createServer } from "lexicon"; 4 5 import API from "./xrpc"; ··· 15 16 server = API(server, ctx); 16 17 17 18 const app = express(); 19 + app.use(cors()); 18 20 app.use(server.xrpc.router); 19 21 20 22 app.listen(process.env.ROCKSKY_XPRC_PORT || 3004, () => {
+3 -1
apps/web/src/api/search.ts
··· 2 2 import { API_URL } from "../consts"; 3 3 4 4 export const search = async (query: string) => { 5 - const response = await axios.get(`${API_URL}/search?q=${query}&size=100`); 5 + const response = await axios.get( 6 + `${API_URL}/xrpc/app.rocksky.feed.search?query=${query}&size=100` 7 + ); 6 8 return response.data; 7 9 };
+6 -1
apps/web/src/layouts/Search/Search.tsx
··· 12 12 import Artist from "../../components/Icons/Artist"; 13 13 import Disc from "../../components/Icons/Disc"; 14 14 import Track from "../../components/Icons/Track"; 15 - import useSearch from "../../hooks/useSearch"; 15 + import useSearch, { useSearchMutation } from "../../hooks/useSearch"; 16 16 17 17 const Link = styled(DefaultLink)` 18 18 color: initial; ··· 29 29 30 30 function Search() { 31 31 const [results, setResults] = useState([]); 32 + 33 + const { mutate, data } = useSearchMutation(); 32 34 33 35 const { search } = useSearch(); 34 36 const { ··· 48 50 // eslint-disable-next-line react-hooks/exhaustive-deps 49 51 const debouncedSearch = useCallback( 50 52 _.debounce(async (keyword) => { 53 + mutate(keyword); 51 54 const data = await search(keyword); 52 55 setResults(data.records); 53 56 }, 300), ··· 62 65 } 63 66 // eslint-disable-next-line react-hooks/exhaustive-deps 64 67 }, [keyword]); 68 + 69 + console.log(">> data", data); 65 70 66 71 return ( 67 72 <>
+1
bun.lock
··· 39 39 "better-sqlite3": "^11.8.1", 40 40 "chalk": "^5.4.1", 41 41 "chanfana": "^2.0.2", 42 + "cors": "^2.8.5", 42 43 "dayjs": "^1.11.13", 43 44 "dotenv": "^16.4.7", 44 45 "drizzle-orm": "^0.44.2",