From 2b4724f39cf0b04e58e458e342dbb660a730d204 Mon Sep 17 00:00:00 2001 From: Tom Collis <22452596+tomcollis@users.noreply.github.com> Date: Tue, 11 Jun 2024 16:39:24 +0100 Subject: [PATCH 1/2] Add simple API documentation --- docs/api.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 docs/api.md diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..f00efc2 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,51 @@ +# Sink API + +Sink has a basic API implementation but it is not stable written yet. + +## API Reference + +### Create Short Link + +```http + POST /api/link/create +``` + +| Header | Description | +| :----- | :------------------------- | +| `authorization` | `Bearer SinkCool` | +| `content-type` | `application/json` | + + +#### Example + +```http + POST /api/link/create + HEADER authorization:Bearer SinkCool, content-type:application/json + BODY { + "url": "https://github.com/ccbikai/Sink/issues/14", + "slug": issue14 + } +``` + +The BODY data must be JSON. + +```http + RESPONSE 201 + BODY { + "link": { + "id": "xpqhaurv5q", + "url": "https://github.com/ccbikai/Sink/issues/14", + slug": "issue14", + "createdAt": 1718119809, + "updatedAt": 1718119809 + } + } +``` + +| Parameter | Type | Description | +| :-------- | :------- | :------------------------- | +| `id` | `string` | This is automatically generated by Sink | +| `url` | `string` | This is confirmation of the submitted URL and is required. | +| `slug` | `string` | This is slug generated by the system, either automatically or from the input (if provided) | +| `createdAt` | `timestamp` | This is automatically generated with a UNIX Timestamp. | +| `updatedAt` | `timestamp` | This is automatically generated with a UNIX Timestamp. | \ No newline at end of file From 686ecd151a5661bce6c24e84dd07442f30a5c4f4 Mon Sep 17 00:00:00 2001 From: ccbikai Date: Wed, 12 Jun 2024 20:28:23 +0800 Subject: [PATCH 2/2] docs: add API Docs --- .node-version | 2 +- README.md | 4 ++++ docs/api.md | 32 +++++++++++++++++--------------- package.json | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.node-version b/.node-version index 07533ba..9a2a0e2 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -v20.11 +v20 diff --git a/README.md b/README.md index 92ee74e..b442909 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,10 @@ We welcome your contributions and PRs. [Configuration Docs](./docs/configuration.md) +## 🔌 API + +[API Docs](./docs/api.md) + ## 🙋🏻 FAQs [FAQs](./docs/faqs.md) diff --git a/docs/api.md b/docs/api.md index f00efc2..7dbd60f 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,6 +1,8 @@ # Sink API -Sink has a basic API implementation but it is not stable written yet. +Writing API documentation manually can be very laborious, and we will automatically generate documents after the official release of [Nitro's OpenAPI](https://nitro.unjs.io/config#openapi). + +This place provides an example of creating a short link API. Other APIs are currently available for viewing through browser developer tools. ## API Reference @@ -15,15 +17,15 @@ Sink has a basic API implementation but it is not stable written yet. | `authorization` | `Bearer SinkCool` | | `content-type` | `application/json` | - #### Example ```http POST /api/link/create - HEADER authorization:Bearer SinkCool, content-type:application/json - BODY { - "url": "https://github.com/ccbikai/Sink/issues/14", - "slug": issue14 + HEADER authorization: Bearer SinkCool + HEADER content-type: application/json + BODY { + "url": "https://github.com/ccbikai/Sink/issues/14", + "slug": "issue14" } ``` @@ -31,14 +33,14 @@ The BODY data must be JSON. ```http RESPONSE 201 - BODY { - "link": { - "id": "xpqhaurv5q", - "url": "https://github.com/ccbikai/Sink/issues/14", - slug": "issue14", - "createdAt": 1718119809, - "updatedAt": 1718119809 - } + BODY { + "link": { + "id": "xpqhaurv5q", + "url": "https://github.com/ccbikai/Sink/issues/14", + "slug": "issue14", + "createdAt": 1718119809, + "updatedAt": 1718119809 + } } ``` @@ -48,4 +50,4 @@ The BODY data must be JSON. | `url` | `string` | This is confirmation of the submitted URL and is required. | | `slug` | `string` | This is slug generated by the system, either automatically or from the input (if provided) | | `createdAt` | `timestamp` | This is automatically generated with a UNIX Timestamp. | -| `updatedAt` | `timestamp` | This is automatically generated with a UNIX Timestamp. | \ No newline at end of file +| `updatedAt` | `timestamp` | This is automatically generated with a UNIX Timestamp. | diff --git a/package.json b/package.json index 9eccaa8..0e4bf33 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "lint-staged": "lint-staged" }, "engines": { - "node": ">=20.11.0" + "node": ">=20" }, "dependencies": { "@unovis/ts": "^1.4.1",