From 4b8c647a92514bbdce94960d36bbbb52f264b1da Mon Sep 17 00:00:00 2001 From: BaggerFast Date: Mon, 3 Jun 2024 00:45:39 +0300 Subject: [PATCH] UPDATE: complete docs for redirects --- doc-app/docs/api/admin/domains.md | 3 +- doc-app/docs/api/anonymous/redirects.md | 50 ++++++++++++++++++++++++- doc-app/docs/api/misc/errors.md | 15 +++++++- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/doc-app/docs/api/admin/domains.md b/doc-app/docs/api/admin/domains.md index b826b86..f9cbbc6 100644 --- a/doc-app/docs/api/admin/domains.md +++ b/doc-app/docs/api/admin/domains.md @@ -41,8 +41,8 @@ Shorter domain names greatly enhance the efficiency and brevity of our service. ``` ### Errors - - [Not unique](../misc/errors.md#notunique) +- [Not valid](../misc/errors.md#notvalid) - [Too many records](../misc/errors.md#tomanyrecords) ## GET @@ -72,6 +72,5 @@ Get all domains - Url: `/api/v1/domains/{id}` ### Errors - - [Not found](../misc/errors.md#errors) - [Is using](../misc/errors.md#isusing) \ No newline at end of file diff --git a/doc-app/docs/api/anonymous/redirects.md b/doc-app/docs/api/anonymous/redirects.md index 5b36cbc..45f9e24 100644 --- a/doc-app/docs/api/anonymous/redirects.md +++ b/doc-app/docs/api/anonymous/redirects.md @@ -4,7 +4,6 @@ This entity records all user interactions with shortened links, collecting infor ### Base requirements - Auth: `NO` - ## CREATE - Method: `POST` - Url: `/api/v1/redirects` @@ -31,4 +30,51 @@ This entity records all user interactions with shortened links, collecting infor - len: `2 < .. < 16` - regex: `^[a-zA-Z]{2,16}$` - path - - len: `2 < .. < 16` \ No newline at end of file + - len: `2 < .. < 16` + +### Example + +```json +{ + "os": "windows", + "device": "Mobile", + "ip": "127.0.0.1", + "userKey": "41c6e485-b373-4723-a31e-3ee767367fbd", + "domain": "sh0.su", + "subdomain": "test", + "path": "fcaz6p" +} +``` + +### Errors +- [Not found](../misc/errors.md#errors) + + +## GET +- Method: `GET` +- Url: `/api/v1/redirects/link?{domain}=&{path}=&{subdomain}=` + +> | name | type | data type | description | +> |-----------|----------|-----------|----------------------------------------| +> | domain | required | string | domain address | +> | subdomain | | string? | subdomain address | +> | path | required | string | url path | + +### Validation +- domain + - len: `5 < .. < 32` + - regex: `^[a-z0-9]+[.:][a-z0-9]{2,}$` +- subdomain + - len: `2 < .. < 16` + - regex: `^[a-zA-Z]{2,16}$` +- path + - len: `2 < .. < 16` + +### Example + +```http +GET {{url}}/api/v1/redirects/link?domain=sh0.su&path=ml6v1s +``` + +### Errors +- [Not found](../misc/errors.md#errors) \ No newline at end of file diff --git a/doc-app/docs/api/misc/errors.md b/doc-app/docs/api/misc/errors.md index 3982eae..6b39e01 100644 --- a/doc-app/docs/api/misc/errors.md +++ b/doc-app/docs/api/misc/errors.md @@ -29,7 +29,7 @@ The record cannot be deleted because it is referenced by other records. ## NotUnique The record cannot be created, because not unique - HttpCode: `409` -- On: `POST` +- On: `POST` `PUT` ### Example ```json @@ -49,4 +49,17 @@ The record cannot be created because the maximum count has been reached "error": "TOO_MANY_RECORDS", "maxAllowedRecords": 10 } +``` + +## NotValid +The record is invalid +- HttpCode: `422` +- On: `POST` `PUT` + +### Example +```json +{ + "error": "BODY_NOT_VALID", + "invalidFields": ["field1", "field2"] +} ``` \ No newline at end of file