-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from doutorfinancas/prodrigues/create_ability_…
…to_redirect_by_a_number_of_times feat: #1 Restrict the access to a shorty URL by the number of redirects
- Loading branch information
Showing
13 changed files
with
284 additions
and
92 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/.idea | ||
/dist | ||
.env | ||
tmp | ||
pun-sho | ||
.env | ||
http-requests/http-client.private.env.json |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE pun_sho.shorties | ||
DROP COLUMN redirection_limit; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE pun_sho.shorties | ||
ADD COLUMN redirection_limit INT DEFAULT 0; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"development": { | ||
"host": "http://localhost:8080" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"development": { | ||
"token": "ThisIsA5uper$ecureAPIToken" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
### Create a short link | ||
|
||
# curl -XPOST {{host}}/api/v1/short | ||
# -H 'token: {{token}}' | ||
# -H 'Content-Type: application/json' | ||
# -d $BODY | ||
POST {{host}}/api/v1/short | ||
token: {{token}} | ||
Content-Type: application/json | ||
|
||
{ | ||
"link": "https://www.brave.com/", | ||
"TTL": "2023-05-25T23:59:59Z", | ||
"redirection_limit": 5, | ||
"qr_code": { | ||
"create": true, | ||
"width" : 50, | ||
"height": 50, | ||
"foreground_color": "#000000", | ||
"background_color": "#ffffff", | ||
"shape": "circle" | ||
} | ||
} | ||
|
||
> {% | ||
client.test("Status", function() { | ||
client.assert(response.status === 201, "Response status is not 201"); | ||
}); | ||
|
||
client.test("Content-Type", function() { | ||
const contentType = response.contentType.mimeType | ||
client.assert(contentType === "application/json", "Response Content-Type is not 'application/json'"); | ||
}); | ||
|
||
client.global.set('shorty_id', response.body.id); | ||
%} | ||
|
||
### Get statistics from a visited link | ||
|
||
# curl -H 'token: {{token}}' {{host}}/api/v1/short/{{shorty_id}} | ||
# * {{shorty_id}} being what was created in the previous test | ||
GET {{host}}/api/v1/short/{{shorty_id}} | ||
token: {{token}} | ||
|
||
> {% | ||
client.test("Status", function() { | ||
client.assert(response.status === 200, "Response status is not 200"); | ||
}); | ||
|
||
client.test("Content-Type", function() { | ||
const contentType = response.contentType.mimeType | ||
client.assert(contentType === "application/json", "Response Content-Type is not 'application/json'"); | ||
}); | ||
%} | ||
|
||
### Get a list of links | ||
|
||
# curl -H 'token: {{token}}' {{host}}/api/v1/short/?limit=20&offset=0 | ||
GET {{host}}/api/v1/short/?limit=20&offset=0 | ||
token: {{token}} | ||
|
||
> {% | ||
client.test("Status", function() { | ||
client.assert(response.status === 200, "Response status is not 200"); | ||
}); | ||
|
||
client.test("Content-Type", function() { | ||
const contentType = response.contentType.mimeType | ||
client.assert(contentType === "application/json", "Response Content-Type is not 'application/json'"); | ||
}); | ||
%} | ||
|
||
### | ||
|
Oops, something went wrong.