@ffflorian/icanhazdadjoke 2.3.7 → 2.4.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.
@@ -9,5 +9,5 @@ export declare class ICanHazDadJoke {
9
9
  * Set a new API URL.
10
10
  * @param url The new API URL.
11
11
  */
12
- setApiUrl(newUrl: string): void;
12
+ setApiUrl(newURL: string): void;
13
13
  }
@@ -1,13 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ICanHazDadJoke = void 0;
4
- const axios_1 = require("axios");
4
+ const api_client_1 = require("@ffflorian/api-client");
5
5
  const ICanHazDadJokeAPI_1 = require("./ICanHazDadJokeAPI");
6
6
  class ICanHazDadJoke {
7
7
  constructor(options) {
8
8
  this.options = Object.assign({ apiUrl: 'https://icanhazdadjoke.com' }, options);
9
- this.apiClient = axios_1.default.create({
10
- baseURL: this.options.apiUrl,
9
+ this.apiClient = new api_client_1.APIClient(this.options.apiUrl, {
11
10
  headers: {
12
11
  Accept: 'application/json',
13
12
  'User-Agent': 'icanhazdadjoke.com API Client (https://github.com/ffflorian/api-clients/tree/main/packages/icanhazdadjoke)',
@@ -19,8 +18,8 @@ class ICanHazDadJoke {
19
18
  * Set a new API URL.
20
19
  * @param url The new API URL.
21
20
  */
22
- setApiUrl(newUrl) {
23
- this.apiClient.defaults.baseURL = newUrl;
21
+ setApiUrl(newURL) {
22
+ this.apiClient.setBaseURL(newURL);
24
23
  }
25
24
  }
26
25
  exports.ICanHazDadJoke = ICanHazDadJoke;
@@ -1,9 +1,9 @@
1
- import type { AxiosInstance } from 'axios';
1
+ import type { APIClient } from '@ffflorian/api-client';
2
2
  import type { ClientOptions, JokeResult, JokeResultWithImage, JokeSearchResult, RequestOptions, SearchOptions } from './Interfaces';
3
3
  export declare class ICanHazDadJokeAPI {
4
- protected readonly apiClient: AxiosInstance;
4
+ protected readonly apiClient: APIClient;
5
5
  protected readonly options: ClientOptions;
6
- constructor(apiClient: AxiosInstance, options: ClientOptions);
6
+ constructor(apiClient: APIClient, options: ClientOptions);
7
7
  /**
8
8
  * Fetch a dad joke by ID.
9
9
  * @see https://icanhazdadjoke.com/api#fetch-a-dad-joke
@@ -52,7 +52,9 @@ class ICanHazDadJokeAPI {
52
52
  getImage(imageUrl) {
53
53
  return __awaiter(this, void 0, void 0, function* () {
54
54
  const { data } = yield this.apiClient.get(imageUrl, {
55
- headers: Object.assign(Object.assign({}, this.apiClient.defaults.headers.get), { Accept: 'image/png' }),
55
+ headers: {
56
+ Accept: 'image/png',
57
+ },
56
58
  responseType: 'arraybuffer',
57
59
  });
58
60
  return data;
package/dist/cli.js CHANGED
@@ -1,5 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
3
36
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
37
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
38
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -12,7 +45,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
45
  Object.defineProperty(exports, "__esModule", { value: true });
13
46
  const commander_1 = require("commander");
14
47
  const fs_1 = require("fs");
15
- const path = require("path");
48
+ const path = __importStar(require("path"));
16
49
  const _1 = require("./");
17
50
  function init() {
18
51
  return __awaiter(this, arguments, void 0, function* (dir = '.') {
package/package.json CHANGED
@@ -2,19 +2,19 @@
2
2
  "author": "Florian Imdahl <git@ffflorian.de>",
3
3
  "bin": "dist/cli.js",
4
4
  "dependencies": {
5
- "axios": "1.12.2",
6
- "commander": "14.0.1"
5
+ "@ffflorian/api-client": "2.1.2",
6
+ "commander": "14.0.2"
7
7
  },
8
8
  "description": "An icanhazdadjoke.com API client with a CLI.",
9
9
  "devDependencies": {
10
10
  "@types/node": "~24",
11
- "rimraf": "6.0.1",
12
- "ts-node": "10.9.2",
13
- "typedoc": "0.28.13",
11
+ "rimraf": "6.1.0",
12
+ "tsx": "4.20.6",
13
+ "typedoc": "0.28.14",
14
14
  "typescript": "5.9.3"
15
15
  },
16
16
  "engines": {
17
- "node": ">= 10.9"
17
+ "node": ">= 21"
18
18
  },
19
19
  "files": [
20
20
  "dist"
@@ -30,13 +30,13 @@
30
30
  "name": "@ffflorian/icanhazdadjoke",
31
31
  "repository": "https://github.com/ffflorian/api-clients/tree/main/packages/icanhazdadjoke",
32
32
  "scripts": {
33
- "build:ts": "tsc",
34
- "build:docs": "typedoc --options ../../typedoc.json --out ../../docs/packages/icanhazdadjoke src/index.ts",
33
+ "build:ts": "tsc -p tsconfig.build.json",
34
+ "build:docs": "typedoc --tsconfig tsconfig.build.json --options ../../typedoc.json --out ../../docs/packages/icanhazdadjoke src/index.ts",
35
35
  "clean": "rimraf dist",
36
36
  "dist": "yarn clean && yarn build:ts",
37
- "start": "ts-node src/cli.ts",
37
+ "start": "tsx src/cli.ts",
38
38
  "test": "exit 0"
39
39
  },
40
- "version": "2.3.7",
41
- "gitHead": "ad816b675937c5075c585f666f180ccd0918021a"
40
+ "version": "2.4.0",
41
+ "gitHead": "b6392f3b78cc68d334526b7ebd5f1375511c769f"
42
42
  }