Demo https://url--shortener.herokuapp.com/
Login/Password: test/test
Fullstack Javascript Web application.
- Express
- LokiJS
- Ava
Go to the resources
folder and create an empty db.local.json
file
npm start
npm test
- React
- Redux
- Jest
npm start
npm test
npm run build
Allowed methods
POST
| GET
| DELETE
POST /link
Parameters should be passed as JSON in the body of the request.
Required parameters
parameter | description |
---|---|
linkURL string |
The original URL to shorten |
cURL (example)
curl -X POST \
http://localhost:4200/link \
-H 'Content-Type: application/json' \
-d '{
"linkURL": "http://www.google.com"
}'
Response (example)
{
"id": "zBnHa0",
"visit": 0,
"linkURL": "http://www.google.com",
"meta": {
"created": 1525783483887,
"version": 0,
"revision": 0
}
}
Error codes
code | description |
---|---|
412 |
Precondition failed, the request body is not valid |
500 |
Internal error |
GET /link
Require authorization header with basic authentication
cURL (example)
curl -X GET \
http://localhost:4200/link \
-H 'Authorization: Basic dGVzdD====' \
-H 'Content-Type: application/json' \
Response (example)
{
[
{
"id": "xmRCyq",
"visit": 1,
"linkURL": "http://google.com",
"meta": {
"created": 1525778635631,
"version": 0,
"revision": 1,
"updated": 1525778635631
}
},
{
"id": "W2gcva",
"visit": 1,
"linkURL": "http://github.com",
"meta": {
"created": 1525779142957,
"version": 0,
"revision": 1,
"updated": 1525778635631
}
}
]
}
Error codes
code | description |
---|---|
401 |
Request had no/invalid Authorization header |
500 |
Internal error |
cURL (example)
GET /link/:identifier
cURL (example)
curl -X GET \
http://localhost:4200/link/W2gcva \
-H 'Content-Type: application/json' \
Redirect 301 to the original URL
Error codes
code | description |
---|---|
404 |
No such item |
500 |
Internal error |
DELETE /link/:identifier
Require authorization header with basic authentication
cURL (example)
curl -X DELETE \
http://localhost:4200/link/W2gcva \
-H 'Authorization: Basic dGVzdD====' \
-H 'Content-Type: application/json' \
Response (example)
{}
Error codes
code | description |
---|---|
404 |
No such item |
500 |
Internal error |