Created
August 12, 2023 04:32
-
-
Save mihai-craita/78d511575f17d4347d5546ef5b30ee42 to your computer and use it in GitHub Desktop.
Justfile using curl as an alternative to postman
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BASE_URL := "http://localhost:3000" | |
### Posts ### | |
# Create a post | |
create-post: | |
@echo "Creating a new post..." | |
@curl -X POST -H "Content-Type: application/json" \ | |
-d '{"title": "New Post", "content": "This is a new post."}' \ | |
{{BASE_URL}}/posts | |
# Read a post by ID | |
read-post ID: | |
@echo "Fetching post with ID: {{ID}}..." | |
@curl {{BASE_URL}}/posts/{{ID}} | |
# Update a post by ID | |
update-post ID: | |
@echo "Updating post with ID: {{ID}}..." | |
@curl -X PUT -H "Content-Type: application/json" \ | |
-d '{"title": "Updated Title"}' \ | |
{{BASE_URL}}/posts/{{ID}} | |
# Delete a post by ID | |
delete-post ID: | |
@echo "Deleting post with ID: {{ID}}..." | |
@curl -X DELETE {{BASE_URL}}/posts/{{ID}} | |
# List all posts | |
list-posts: | |
@echo "Listing all posts..." | |
@curl {{BASE_URL}}/posts | |
### Comments ### | |
# Create a comment | |
create-comment: | |
@echo "Creating a new comment..." | |
@curl -X POST -H "Content-Type: application/json" \ | |
-d '{"postId": 1, "text": "This is a comment."}' \ | |
{{BASE_URL}}/comments | |
# Read a comment by ID | |
read-comment ID: | |
@echo "Fetching comment with ID: {{ID}}..." | |
@curl {{BASE_URL}}/comments/{{ID}} | |
# Update a comment by ID | |
update-comment ID: | |
@echo "Updating comment with ID: {{ID}}..." | |
@curl -X PUT -H "Content-Type: application/json" \ | |
-d '{"text": "Updated comment text."}' \ | |
{{BASE_URL}}/comments/{{ID}} | |
# Delete a comment by ID | |
delete-comment ID: | |
@echo "Deleting comment with ID: {{ID}}..." | |
@curl -X DELETE {{BASE_URL}}/comments/{{ID}} | |
# List all comments | |
list-comments: | |
@echo "Listing all comments..." | |
@curl {{BASE_URL}}/comments | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment