Spaces:
Sleeping
Sleeping
Download manual/posts.sh from dangkhoa2016/Nodejs-JSON-API-Server: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/dangkhoa2016/Nodejs-JSON-API-Server/resolve/42e30c2fc13d198cc76d79446c2a4308bbca4162/manual/posts.sh
- Command line
-
hf download hf://spaces/dangkhoa2016/Nodejs-JSON-API-Server@42e30c2fc13d198cc76d79446c2a4308bbca4162/manual/posts.sh
-
curl -L -o posts.sh https://huggingface.co/spaces/dangkhoa2016/Nodejs-JSON-API-Server/resolve/42e30c2fc13d198cc76d79446c2a4308bbca4162/manual/posts.sh
1.21 kB
| BASE_URL=http://localhost:3000 | |
| # List (first 5) | |
| curl -s "$BASE_URL/api/posts?_limit=5" | |
| # Get by id | |
| curl -s "$BASE_URL/api/posts/1" | |
| # Filter by userId | |
| curl -s "$BASE_URL/api/posts?userId=1" | |
| # Search | |
| curl -s "$BASE_URL/api/posts?q=qui" | |
| # Paginate | |
| curl -s "$BASE_URL/api/posts?_page=2&_limit=3" | |
| # Sort by title desc | |
| curl -s "$BASE_URL/api/posts?_sort=title&_order=desc" | |
| # Create | |
| curl -s -X POST "$BASE_URL/api/posts" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"userId":1,"title":"new post","body":"hello world"}' | |
| # Update (partial) | |
| curl -s -X PATCH "$BASE_URL/api/posts/1" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"title":"updated title"}' | |
| # Replace (full) | |
| curl -s -X PUT "$BASE_URL/api/posts/1" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"userId":1,"title":"sunt aut facere repellat provident occaecati excepturi optio reprehenderit","body":"quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"}' | |
| # Delete the post we just created (safe — no dependent comments) | |
| curl -s -X DELETE "$BASE_URL/api/posts/101" | |
| # Nested: post's comments | |
| curl -s "$BASE_URL/api/posts/1/comments" | |