Skip to content

Commit

Permalink
chore(postman): add collection and environment
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Oct 4, 2020
1 parent 7f8d700 commit 9e1dcf7
Show file tree
Hide file tree
Showing 2 changed files with 207 additions and 0 deletions.
173 changes: 173 additions & 0 deletions postman/urlsh.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{
"info": {
"_postman_id": "bd2d4683-d7ea-4273-9c28-5e34ae0d774c",
"name": "urlsh",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "index",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}",
"host": [
"{{baseUrl}}"
]
},
"description": "# GET /\n\nIndex route for healtcheck.\n\n## Response payload\n\n```json\n{\n \"status\": 200,\n \"message\": \"it works\"\n}\n```\n"
},
"response": []
},
{
"name": "client.create.urls",
"event": [
{
"listen": "prerequest",
"script": {
"id": "b6ee25f3-5fc1-4a43-b5a1-560706b4f9fb",
"exec": [
"pm.environment.set(\"rand\", Math.floor(Math.random() * 1000));"
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"id": "272c1f08-8db6-4551-9bb0-c9a02c0b58a7",
"exec": [
"pm.environment.set(\"shortCode\", pm.response.json().short_code);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"url\": \"{{baseUrl}}/very/long/url/{{rand}}\",\n \"keywords\": [\"kw{{rand}}\"]\n}\n",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/api/urls",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"urls"
]
},
"description": "# POST /api/urls\n\nCreates a new short code for given URL.\n\n## Request example\n\n```json\n{\n \"url\": \"http://somedomain.com/some/very/long/url\",\n \"expires_on\": \"\",\n \"keywords\": [\"key\", \"word\"]\n}\n```\n\n## Response example\n\n```json\n{\n \"status\": 200,\n \"short_code\": \"qaFxz\",\n \"short_url\": \"http://localhost:1000/qaFxz\"\n}\n```\n"
},
"response": []
},
{
"name": "redirect",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/{{shortCode}}",
"host": [
"{{baseUrl}}"
],
"path": [
"{{shortCode}}"
]
},
"description": "# GET /{{shortCode}}\n\nRedirects the shortcode to original long URL.\n\n## Response payload\n\nIn case short code exists it responds with 302 redirect.\n\nIf the short code is expired or deleted, it responds like so:\n\n```json\n{\n \"status\": 410,\n \"message\": \"requested resource is not available\"\n}\n```\n"
},
"response": []
},
{
"name": "admin.list.urls",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{token}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/api/admin/urls?page={{page}}&keyword={{keyword}}&short_code={{shortCode}}",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"admin",
"urls"
],
"query": [
{
"key": "page",
"value": "{{page}}"
},
{
"key": "keyword",
"value": "{{keyword}}"
},
{
"key": "short_code",
"value": "{{shortCode}}"
}
]
},
"description": "# GET /api/admin/urls\n\n## Authentication\n\nToken required in `Authorization` header like so:\n```ini\nAuthorization: Bearer <token>\n```\n\n## Request query\n\nThe query params are optional.\n\n```ini\npage=<int>\nshort_code=<str> (not short url but code)\nkeyword=<str>\n```\n\n*Examples*\n- `/api/admin/urls?short_code=somecode`\n- `/api/admin/urls?page=1&keyword=something`\n\n## Response example\n\nResponse contains multiple matching url object inside `urls` array.\n\n```json\n{\n \"status\": 200,\n \"urls\": [\n {\n \"short_code\": \"X5JkFd\",\n \"origin_url\": \"http://somedomain.com/some/very/long/url\",\n \"hits\": 1,\n \"is_deleted\": false,\n \"expires_on\": \"9999-01-01T00:00:00Z\"\n }\n ]\n}\n```\n\n"
},
"response": []
},
{
"name": "admin.delete.url",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{token}}",
"type": "string"
}
]
},
"method": "DELETE",
"header": [],
"url": {
"raw": "{{baseUrl}}/api/admin/urls?short_code={{shortCode}}",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"admin",
"urls"
],
"query": [
{
"key": "short_code",
"value": "{{shortCode}}"
}
]
},
"description": "# DELETE /api/admin/urls\n\n## Authentication\n\nToken required in `Authorization` header like so:\n```ini\nAuthorization: Bearer <token>\n```\n\n## Request query\n\nQuery param `short_code` is requied.\n\n*Example*: `/api/admin/urls?short_code=somecode`\n\n## Response example\n\nIf delete success:\n\n```json\n{\n \"status\": 200,\n \"deleted\": true\n}\n```\n\nIf the code does not exist:\n\n```json\n{\n \"status\": 404,\n \"message\": \"the given short code is not found\"\n}\n```\n"
},
"response": []
}
],
"protocolProfileBehavior": {}
}
34 changes: 34 additions & 0 deletions postman/urlsh.postman_environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"id": "850625c3-45d4-423e-8004-6f3011e4e661",
"name": "urlsh",
"values": [
{
"key": "baseUrl",
"value": "http://localhost:1000",
"enabled": true
},
{
"key": "token",
"value": "qazwsxedcrfvtgbyhnujmikolp",
"enabled": true
},
{
"key": "shortCode",
"value": "x",
"enabled": true
},
{
"key": "keyword",
"value": "",
"enabled": true
},
{
"key": "page",
"value": "1",
"enabled": true
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2020-10-04T04:29:04.737Z",
"_postman_exported_using": "Postman/7.33.1"
}

0 comments on commit 9e1dcf7

Please sign in to comment.