@short.io/client-node 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Short.io Node.js SDK
2
2
 
3
3
  The Short.io Node.js official SDK client is a library that allows you to integrate [short.io](https://short.io) URL shortening and link management API with your Node.js application in an easy and elegant way.
4
+ This SDK contains methods for working with links and domains.
4
5
 
5
6
  ## API reference
6
7
 
@@ -8,7 +9,7 @@ See the [API docs](https://developers.short.io/reference) for more information.
8
9
 
9
10
  ## Installing
10
11
 
11
- To install this package, type:
12
+ To install the SDK, run:
12
13
 
13
14
  ```sh
14
15
  npm i @short.io/client-node
@@ -17,59 +18,48 @@ npm i @short.io/client-node
17
18
  ## Getting Started
18
19
 
19
20
  First you need to get your API key from the Short.io dashboard in the [Integrations & API](https://app.short.io/settings/integrations/api-key) section.
20
- This SDK contains methods for working with links, domains and statistics. Import the Shortio class:
21
+ Then you need to set the configuration for the client:
21
22
 
22
23
  ```js
23
- import { Shortio } from "shortio";
24
- ```
25
-
26
- ## Usage
27
-
28
- Then create an instance of the Shortio class, and pass your API key as the first parameter:
24
+ import { client } from "@short.io/client-node";
29
25
 
30
- ```js
31
- const shortio = new Shortio("YOUR_API_KEY");
26
+ client.setConfig({
27
+ baseUrl: "https://api.short.io",
28
+ headers: {
29
+ Authorization: "YOUR_API_KEY",
30
+ },
31
+ });
32
32
  ```
33
33
 
34
- To get the domain list, you can use the following code:
35
-
36
- ```js
37
- const domains = await shortio.domain.list();
38
- ```
34
+ ## Usage
39
35
 
40
- Get the link list of the first domain above:
36
+ Import the needed methods from the SDK and use them in your code:
41
37
 
42
38
  ```js
43
- const links = await shortio.link.list(domains[0].id);
39
+ import {
40
+ client,
41
+ getApiDomains,
42
+ getLinksExpand,
43
+ // and other needed methods
44
+ } from "@short.io/client-node";
44
45
  ```
45
46
 
46
- Get the link statistics of the first link above:
47
+ Pass created client to the methods:
47
48
 
48
49
  ```js
49
- const stats = await shortio.statistics.getByLink(links[0].idString);
50
+ const domainsResp = await getApiDomains({ client });
50
51
  ```
51
52
 
52
- Create links:
53
+ `domainsResp.data` will contain the list of domains.
53
54
 
54
55
  ```js
55
- const link = await shortio.link.create({
56
- domain: "link.example.com",
57
- path: "example",
58
- originalURL: "https://example.com",
56
+ const linkResp = await getLinksExpand({
57
+ client,
58
+ query: {
59
+ domain: "your_domain.com",
60
+ path: "lnk_abc123_abcde12345,
61
+ },
59
62
  });
60
- console.log(link.shortURL); // https://link.example.com/example
61
-
62
- const publicLink = await shortio.link.createPublic({
63
- domain: "link.example.com",
64
- originalURL: "https://example.com",
65
- publicAPIKey: "PUBLIC_API_KEY",
66
- });
67
- console.log(publicLink.shortURL); // https://link.example.com/a83t48
63
+ ```
68
64
 
69
- const secureLink = await shortio.link.createSecure({
70
- domain: "link.example.com",
71
- publicAPIKey: "PUBLIC_API_KEY",
72
- originalURL: "https://example.com",
73
- });
74
- console.log(secureLink.shortURL); // https://link.example.com/a83t48#ta95me8
75
- ```
65
+ `linkResp.data` will contain the expanded link.
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@short.io/client-node",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "types": "dist/index.d.ts",
9
9
  "scripts": {
10
- "compile": "tsc",
11
- "format": "eslint --cache --ext .ts . && prettier --write \"src/**/*.ts\"",
12
- "prepare": "npm run compile",
13
- "prepublishOnly": "npm run format"
10
+ "generate": "node --experimental-strip-types openapi/fetch.ts && openapi-ts -f openapi/config.ts",
11
+ "compile": "tsc && tsc-alias",
12
+ "prepare": "npm run compile"
14
13
  },
15
14
  "repository": {
16
15
  "type": "git",
@@ -18,7 +17,10 @@
18
17
  },
19
18
  "keywords": [
20
19
  "short.io",
21
- "api"
20
+ "api",
21
+ "client",
22
+ "node",
23
+ "sdk"
22
24
  ],
23
25
  "author": "",
24
26
  "license": "ISC",
@@ -28,9 +30,17 @@
28
30
  "homepage": "https://github.com/Short-io/client-node#readme",
29
31
  "prettier": "@short.io/eslint-config/prettier",
30
32
  "devDependencies": {
31
- "@short.io/eslint-config": "npm:@short.io/style-guide@^1.5.0",
32
- "@types/node": "^18.14.0",
33
- "eslint": "^8.34.0",
34
- "typescript": "^5.0.0"
35
- }
33
+ "@eslint/js": "^9.16.0",
34
+ "@hey-api/openapi-ts": "^0.58.0",
35
+ "@types/node": "^22.10.1",
36
+ "eslint": "^9.16.0",
37
+ "globals": "^15.13.0",
38
+ "tsc-alias": "^1.8.10",
39
+ "typescript": "^5.7.2",
40
+ "typescript-eslint": "^8.17.0"
41
+ },
42
+ "dependencies": {
43
+ "@hey-api/client-fetch": "^0.5.0"
44
+ },
45
+ "packageManager": "yarn@1.22.22+sha256.c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca"
36
46
  }