Skip to content

Commit 9c8810e

Browse files
Replace apiUrl by baseUrl.
1 parent 62dd3ee commit 9c8810e

6 files changed

Lines changed: 310 additions & 252 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
build/
22
dist/
3+
docs/
34
node_modules/
45
typings/
56

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
## [4.3.0] - 2021-12-14
1111
### Added
1212
- New `parse` method in IpregistryClient for parsing user-agent header values.
13+
### Deprecated
14+
- Deprecate `IpregistryConfigBuilder.withApiUrl` in favor of `IpregistryConfigBuilder.withBaseUrl`.
1315

1416
## [4.2.0] - 2021-10-26
1517
### Added

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"lint": "./node_modules/.bin/tslint -p tsconfig.json",
4646
"prepack": "npm run clean && npm run build",
4747
"pretest": "npm run clean && npm run build",
48-
"test:integration": "mocha -r ts-node/register integration_test/**/*.ts"
48+
"test:integration": "mocha -r ts-node/register integration_test/**/*.ts",
49+
"tsdoc": "yarn typedoc --out docs ./src/"
4950
},
5051
"author": "Ipregistry <support@ipregistry.co>",
5152
"devDependencies": {
@@ -56,6 +57,7 @@
5657
"mocha": "^9.1.3",
5758
"ts-node": "^10.4.0",
5859
"tslint": "^6.1.3",
60+
"typedoc": "^0.22.10",
5961
"typescript": "^4.5.4",
6062
"webpack": "^5.65.0",
6163
"webpack-cli": "^4.9.1"
@@ -70,6 +72,6 @@
7072
"engines": {
7173
"node": ">=10.0.0"
7274
},
73-
"engineStrict" : true,
75+
"engineStrict": true,
7476
"private": false
7577
}

src/index.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ export class IpregistryConfig {
2626

2727
public readonly apiKey: string;
2828

29-
public readonly apiUrl: string = 'https://api.ipregistry.co';
29+
public readonly baseUrl: string = 'https://api.ipregistry.co';
3030

3131
public readonly timeout: number = 15000;
3232

33-
constructor(apiKey: string, apiUrl: string, timeout: number) {
33+
constructor(apiKey: string, baseUrl: string, timeout: number) {
3434
this.apiKey = apiKey;
3535

36-
if (apiUrl) {
37-
this.apiUrl = apiUrl;
36+
if (baseUrl) {
37+
this.baseUrl = baseUrl;
3838
}
3939

4040
if (timeout) {
@@ -48,16 +48,24 @@ export class IpregistryConfigBuilder {
4848

4949
private apiKey: string;
5050

51-
private apiUrl: string = 'https://api.ipregistry.co';
51+
private baseUrl: string = 'https://api.ipregistry.co';
5252

5353
private timeout: number = 15000;
5454

5555
constructor(apiKey: string) {
5656
this.apiKey = apiKey;
5757
}
5858

59+
/*
60+
* Use the new {@link IpregistryConfigBuilder.withBaseUrl} method instead.
61+
*/
5962
public withApiUrl(apiUrl: string): IpregistryConfigBuilder {
60-
this.apiUrl = apiUrl;
63+
this.baseUrl = apiUrl;
64+
return this;
65+
}
66+
67+
public withBaseUrl(baseUrl: string): IpregistryConfigBuilder {
68+
this.baseUrl = baseUrl;
6169
return this;
6270
}
6371

@@ -67,7 +75,7 @@ export class IpregistryConfigBuilder {
6775
}
6876

6977
public build(): IpregistryConfig {
70-
return new IpregistryConfig(this.apiKey, this.apiUrl, this.timeout);
78+
return new IpregistryConfig(this.apiKey, this.baseUrl, this.timeout);
7179
}
7280

7381
}

src/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export class DefaultRequestHandler implements IpregistryRequestHandler {
246246
}
247247

248248
protected buildApiUrl(path: string, options?: IpregistryOption[]) {
249-
let result = `${this.config.apiUrl}/${path ? path : ''}`;
249+
let result = `${this.config.baseUrl}/${path ? path : ''}`;
250250

251251
if (options) {
252252
let prefix = '?';

0 commit comments

Comments
 (0)