@lorenzopant/tmdb 1.0.0 → 1.0.2
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/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +71 -0
- package/LICENSE +21 -0
- package/README.md +15 -47
- package/dist/client.js +7 -3
- package/dist/endpoints/movie_lists.js +9 -5
- package/dist/endpoints/movies.js +21 -17
- package/dist/endpoints/search.js +7 -3
- package/dist/errors/messages.js +5 -2
- package/dist/errors/tmdb.js +5 -1
- package/dist/images/images.js +7 -3
- package/dist/index.js +22 -3
- package/dist/tmdb.js +17 -13
- package/dist/types/common.js +2 -1
- package/dist/types/countries.js +4 -1
- package/dist/types/enums.js +5 -2
- package/dist/types/images.js +10 -7
- package/dist/types/index.js +24 -8
- package/dist/types/intl.d.ts +1 -0
- package/dist/types/intl.js +1 -0
- package/dist/types/lang.js +4 -1
- package/dist/types/movies.js +2 -1
- package/dist/types/params.js +2 -1
- package/dist/types/utility.js +2 -1
- package/package.json +13 -11
- package/tsconfig.json +3 -3
- package/dist/tests/images/images.test.d.ts +0 -2
- package/dist/tests/images/images.test.d.ts.map +0 -1
- package/dist/tests/images/images.test.js +0 -43
- package/dist/tests/movie_list/movie_list.integration.test.d.ts +0 -2
- package/dist/tests/movie_list/movie_list.integration.test.d.ts.map +0 -1
- package/dist/tests/movie_list/movie_list.integration.test.js +0 -32
- package/dist/tests/movies/movies.integration.test.d.ts +0 -2
- package/dist/tests/movies/movies.integration.test.d.ts.map +0 -1
- package/dist/tests/movies/movies.integration.test.js +0 -163
- package/dist/tests/movies/movies.test.d.ts +0 -2
- package/dist/tests/movies/movies.test.d.ts.map +0 -1
- package/dist/tests/movies/movies.test.js +0 -40
- package/dist/tests/search/search.integration.test.d.ts +0 -2
- package/dist/tests/search/search.integration.test.d.ts.map +0 -1
- package/dist/tests/search/search.integration.test.js +0 -23
- package/dist/tests/tmdb.test.d.ts +0 -2
- package/dist/tests/tmdb.test.d.ts.map +0 -1
- package/dist/tests/tmdb.test.js +0 -12
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
+
overall community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
+
advances of any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
l.pantano97@gmail.com.
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
|
86
|
+
of actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
|
93
|
+
permanent ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
+
the community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.0, available at
|
|
119
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
122
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
+
|
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
|
125
|
+
|
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
128
|
+
https://www.contributor-covenant.org/translations.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Contributing to tmdb-api-ts
|
|
2
|
+
|
|
3
|
+
Thank you for considering contributing to **tmdb-api-ts**! Whether it's bug reports, feature requests, documentation improvements, or code contributions — all help is appreciated 🙌
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🧰 Getting Started
|
|
8
|
+
|
|
9
|
+
1. Fork the repository and clone it locally.
|
|
10
|
+
2. Install dependencies:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pnpm install
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
3. Run the development server and test suite:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm dev
|
|
20
|
+
pnpm test
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 🧪 Running Tests
|
|
26
|
+
|
|
27
|
+
We use [Vitest](https://vitest.dev/) for testing.
|
|
28
|
+
|
|
29
|
+
To run tests:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To generate a coverage report:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pnpm test --coverage
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## ✍️ Code Style
|
|
44
|
+
|
|
45
|
+
- Use **TypeScript**
|
|
46
|
+
- Use **named exports** where possible
|
|
47
|
+
- Follow the established file structure (`src/`, `types/`, `tests/`, etc.)
|
|
48
|
+
- Use `pnpm lint` and `pnpm format` before submitting a PR
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 🧩 Submitting a Pull Request
|
|
53
|
+
|
|
54
|
+
1. Create a new branch from `main`
|
|
55
|
+
2. Follow the PR template if available
|
|
56
|
+
3. Provide a clear description of what you changed and why
|
|
57
|
+
4. Include related issue numbers if applicable
|
|
58
|
+
5. Ensure all tests pass and types are correct
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 🗃 Feature Requests & Bugs
|
|
63
|
+
|
|
64
|
+
- Open an issue describing the problem or idea
|
|
65
|
+
- Provide examples if possible (stack traces, API request/response, etc.)
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 🙌 Thank You
|
|
70
|
+
|
|
71
|
+
You're helping improve the developer experience for people building with the TMDB API in TypeScript. Thank you for your contributions!
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 @lorenzopant
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,27 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
A **TypeScript-first** lightweight client for [The Movie Database (TMDB)](https://developer.themoviedb.org/docs/getting-started) API.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
Feel free to open pull requests on the project repository
|
|
7
|
-
[tmdb-api-ts](https://github.com/lorenzopantano/tmdb-api-ts)
|
|
5
|
+
This package is open-source and will be updated regularly with new features.
|
|
6
|
+
Feel free to open pull requests on the project repository.
|
|
8
7
|
|
|
9
8
|
- 📦 Full TypeScript support
|
|
10
9
|
- 🔥 Simple and tiny wrapper
|
|
11
|
-
- 🚀 Designed for server-side and frontend use (React, Vue, etc.)
|
|
12
|
-
|
|
10
|
+
- 🚀 Designed for server-side and frontend use (NextJS, React, Vue, etc.)
|
|
11
|
+
|
|
12
|
+
## Full documentation is available at [@lorenzopant/tmdb](https://lorenzopant-docs.vercel.app/)
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
npm install tmdb
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
or
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
yarn add tmdb-api-ts
|
|
19
|
+
npm install @lorenzopant/tmdb
|
|
26
20
|
```
|
|
27
21
|
|
|
28
22
|
---
|
|
@@ -30,7 +24,7 @@ yarn add tmdb-api-ts
|
|
|
30
24
|
## Usage
|
|
31
25
|
|
|
32
26
|
```typescript
|
|
33
|
-
import { TMDB } from 'tmdb
|
|
27
|
+
import { TMDB } from '@lorenzopant/tmdb';
|
|
34
28
|
|
|
35
29
|
const tmdb = new TMDB('your_access_token');
|
|
36
30
|
|
|
@@ -75,7 +69,7 @@ const tmdb = new TMDB(accessToken: string);
|
|
|
75
69
|
Search for movies:
|
|
76
70
|
|
|
77
71
|
```typescript
|
|
78
|
-
tmdb.search.movies("Fight Club");
|
|
72
|
+
tmdb.search.movies({ query: "Fight Club" });
|
|
79
73
|
```
|
|
80
74
|
|
|
81
75
|
Returns a **typed response** containing movies.
|
|
@@ -99,48 +93,22 @@ Returns a **typed response** containing movies.
|
|
|
99
93
|
|
|
100
94
|
### `Movie`
|
|
101
95
|
|
|
102
|
-
|
|
96
|
+
Details, alternative titles, changes, credits, external IDs and more:
|
|
103
97
|
|
|
104
98
|
```typescript
|
|
105
|
-
tmdb.movie.details(550);
|
|
106
|
-
tmdb.movie.alternative_titles(550);
|
|
107
|
-
tmdb.movie.changes(550);
|
|
108
|
-
tmdb.movie.credits(550);
|
|
109
|
-
tmdb.movie.external_ids(550);
|
|
99
|
+
tmdb.movie.details({ movie_id: 550 });
|
|
100
|
+
tmdb.movie.alternative_titles({ movie_id: 550 });
|
|
101
|
+
tmdb.movie.changes({ movie_id: 550 });
|
|
102
|
+
tmdb.movie.credits({ movie_id: 550 });
|
|
103
|
+
tmdb.movie.external_ids({ movie_id: 550 });
|
|
110
104
|
|
|
111
|
-
...
|
|
105
|
+
...and more
|
|
112
106
|
```
|
|
113
107
|
|
|
114
108
|
Returns a **typed response** containing movies.
|
|
115
109
|
|
|
116
110
|
---
|
|
117
111
|
|
|
118
|
-
## Error Handling
|
|
119
|
-
|
|
120
|
-
All errors thrown from the TMDB API are wrapped in a `TMDBError` class.
|
|
121
|
-
|
|
122
|
-
You can catch them:
|
|
123
|
-
|
|
124
|
-
```typescript
|
|
125
|
-
catch (error) {
|
|
126
|
-
if (error instanceof TMDBError) {
|
|
127
|
-
console.log(error.message);
|
|
128
|
-
console.log(error.http_status_code);
|
|
129
|
-
console.log(error.tmdb_status_code);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
Properties available:
|
|
135
|
-
|
|
136
|
-
- `message`
|
|
137
|
-
- `http_status_code`
|
|
138
|
-
- `tmdb_status_code`
|
|
139
|
-
|
|
140
|
-
If the TMDB service is unreachable or returns unexpected errors, `tmdb_status_code` is set to `-1`.
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
112
|
## Requirements
|
|
145
113
|
|
|
146
114
|
- Node.js 18+ recommended
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiClient = void 0;
|
|
4
|
+
const tmdb_1 = require("./errors/tmdb");
|
|
5
|
+
class ApiClient {
|
|
3
6
|
accessToken;
|
|
4
7
|
baseUrl = "https://api.themoviedb.org/3";
|
|
5
8
|
constructor(accessToken) {
|
|
@@ -37,7 +40,8 @@ export class ApiClient {
|
|
|
37
40
|
console.error(`Unknown error: ${error}`);
|
|
38
41
|
// If response is not JSON, fallback to HTTP status text
|
|
39
42
|
}
|
|
40
|
-
const error = new TMDBError(errorMessage, res.status, tmdbStatusCode);
|
|
43
|
+
const error = new tmdb_1.TMDBError(errorMessage, res.status, tmdbStatusCode);
|
|
41
44
|
throw error;
|
|
42
45
|
}
|
|
43
46
|
}
|
|
47
|
+
exports.ApiClient = ApiClient;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MovieListsAPI = exports.MovieListEndpoints = void 0;
|
|
4
|
+
const movies_1 = require("./movies");
|
|
5
|
+
var MovieListEndpoints;
|
|
3
6
|
(function (MovieListEndpoints) {
|
|
4
7
|
MovieListEndpoints["NOW_PLAYING"] = "/now_playing";
|
|
5
8
|
MovieListEndpoints["POPULAR"] = "/popular";
|
|
6
9
|
MovieListEndpoints["TOP_RATED"] = "/top_rated";
|
|
7
10
|
MovieListEndpoints["UPCOMING"] = "/upcoming";
|
|
8
|
-
})(MovieListEndpoints || (MovieListEndpoints = {}));
|
|
9
|
-
|
|
11
|
+
})(MovieListEndpoints || (exports.MovieListEndpoints = MovieListEndpoints = {}));
|
|
12
|
+
class MovieListsAPI {
|
|
10
13
|
client;
|
|
11
14
|
defaultOptions;
|
|
12
15
|
constructor(client, defaultOptions = {}) {
|
|
@@ -24,7 +27,7 @@ export class MovieListsAPI {
|
|
|
24
27
|
* @returns Specific to endpoint (MovieListResult)
|
|
25
28
|
*/
|
|
26
29
|
fetch_movie_list(endpoint, params = {}) {
|
|
27
|
-
return this.client.request(MOVIE_ENDPOINTS.MOVIE + endpoint, this.withDefaults(params));
|
|
30
|
+
return this.client.request(movies_1.MOVIE_ENDPOINTS.MOVIE + endpoint, this.withDefaults(params));
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
33
|
* Now Playing
|
|
@@ -75,3 +78,4 @@ export class MovieListsAPI {
|
|
|
75
78
|
return this.fetch_movie_list(MovieListEndpoints.UPCOMING, params);
|
|
76
79
|
}
|
|
77
80
|
}
|
|
81
|
+
exports.MovieListsAPI = MovieListsAPI;
|
package/dist/endpoints/movies.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MoviesAPI = exports.MOVIE_ENDPOINTS = void 0;
|
|
4
|
+
exports.MOVIE_ENDPOINTS = {
|
|
2
5
|
MOVIE: "/movie",
|
|
3
6
|
ALTERNATIVE_TITLES: "/alternative_titles",
|
|
4
7
|
CREDITS: "/credits",
|
|
@@ -20,7 +23,7 @@ export const MOVIE_ENDPOINTS = {
|
|
|
20
23
|
// ADD RATING
|
|
21
24
|
// DELETE RATING
|
|
22
25
|
};
|
|
23
|
-
|
|
26
|
+
class MoviesAPI {
|
|
24
27
|
client;
|
|
25
28
|
defaultOptions;
|
|
26
29
|
constructor(client, options = {}) {
|
|
@@ -40,7 +43,7 @@ export class MoviesAPI {
|
|
|
40
43
|
*/
|
|
41
44
|
async details(params) {
|
|
42
45
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
43
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}`;
|
|
46
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}`;
|
|
44
47
|
return this.client.request(endpoint, { language, ...rest });
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
@@ -54,7 +57,7 @@ export class MoviesAPI {
|
|
|
54
57
|
* @reference https://developer.themoviedb.org/reference/movie-alternative-titles
|
|
55
58
|
*/
|
|
56
59
|
async alternative_titles(params) {
|
|
57
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.ALTERNATIVE_TITLES}`;
|
|
60
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.ALTERNATIVE_TITLES}`;
|
|
58
61
|
return this.client.request(endpoint, params);
|
|
59
62
|
}
|
|
60
63
|
/**
|
|
@@ -68,7 +71,7 @@ export class MoviesAPI {
|
|
|
68
71
|
* @reference https://developer.themoviedb.org/reference/movie-credits
|
|
69
72
|
*/
|
|
70
73
|
async credits(params) {
|
|
71
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.CREDITS}`;
|
|
74
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.CREDITS}`;
|
|
72
75
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
73
76
|
return this.client.request(endpoint, { language, ...rest });
|
|
74
77
|
}
|
|
@@ -84,7 +87,7 @@ export class MoviesAPI {
|
|
|
84
87
|
* @reference https://developer.themoviedb.org/reference/movie-external-ids
|
|
85
88
|
*/
|
|
86
89
|
async external_ids(params) {
|
|
87
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.EXTERNAL_IDS}`;
|
|
90
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.EXTERNAL_IDS}`;
|
|
88
91
|
return this.client.request(endpoint);
|
|
89
92
|
}
|
|
90
93
|
/**
|
|
@@ -98,7 +101,7 @@ export class MoviesAPI {
|
|
|
98
101
|
* @reference https://developer.themoviedb.org/reference/movie-keywords
|
|
99
102
|
*/
|
|
100
103
|
async keywords(params) {
|
|
101
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.KEYWORDS}`;
|
|
104
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.KEYWORDS}`;
|
|
102
105
|
return this.client.request(endpoint);
|
|
103
106
|
}
|
|
104
107
|
/**
|
|
@@ -116,7 +119,7 @@ export class MoviesAPI {
|
|
|
116
119
|
* @reference https://developer.themoviedb.org/reference/movie-changes
|
|
117
120
|
*/
|
|
118
121
|
async changes(params) {
|
|
119
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.CHANGES}`;
|
|
122
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.CHANGES}`;
|
|
120
123
|
return this.client.request(endpoint, params);
|
|
121
124
|
}
|
|
122
125
|
/**
|
|
@@ -136,7 +139,7 @@ export class MoviesAPI {
|
|
|
136
139
|
*/
|
|
137
140
|
async images(params) {
|
|
138
141
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
139
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.IMAGES}`;
|
|
142
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.IMAGES}`;
|
|
140
143
|
return this.client.request(endpoint, { language, ...rest });
|
|
141
144
|
}
|
|
142
145
|
/**
|
|
@@ -149,7 +152,7 @@ export class MoviesAPI {
|
|
|
149
152
|
* @reference https://developer.themoviedb.org/reference/movie-latest-id
|
|
150
153
|
*/
|
|
151
154
|
async latest() {
|
|
152
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}${MOVIE_ENDPOINTS.LATEST}`;
|
|
155
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}${exports.MOVIE_ENDPOINTS.LATEST}`;
|
|
153
156
|
return this.client.request(endpoint);
|
|
154
157
|
}
|
|
155
158
|
/**
|
|
@@ -166,7 +169,7 @@ export class MoviesAPI {
|
|
|
166
169
|
*/
|
|
167
170
|
async recommendations(params) {
|
|
168
171
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
169
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.RECOMMENDATIONS}`;
|
|
172
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.RECOMMENDATIONS}`;
|
|
170
173
|
return this.client.request(endpoint, { language, ...rest });
|
|
171
174
|
}
|
|
172
175
|
/**
|
|
@@ -186,7 +189,7 @@ export class MoviesAPI {
|
|
|
186
189
|
* @reference https://developer.themoviedb.org/reference/movie-release-dates
|
|
187
190
|
*/
|
|
188
191
|
async release_dates(params) {
|
|
189
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.RELEASE_DATES}`;
|
|
192
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.RELEASE_DATES}`;
|
|
190
193
|
return this.client.request(endpoint);
|
|
191
194
|
}
|
|
192
195
|
/**
|
|
@@ -202,7 +205,7 @@ export class MoviesAPI {
|
|
|
202
205
|
*/
|
|
203
206
|
async reviews(params) {
|
|
204
207
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
205
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.REVIEWS}`;
|
|
208
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.REVIEWS}`;
|
|
206
209
|
return this.client.request(endpoint, { language, ...rest });
|
|
207
210
|
}
|
|
208
211
|
/**
|
|
@@ -220,7 +223,7 @@ export class MoviesAPI {
|
|
|
220
223
|
*/
|
|
221
224
|
async similar(params) {
|
|
222
225
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
223
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.SIMILAR}`;
|
|
226
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.SIMILAR}`;
|
|
224
227
|
return this.client.request(endpoint, { language, ...rest });
|
|
225
228
|
}
|
|
226
229
|
/**
|
|
@@ -235,7 +238,7 @@ export class MoviesAPI {
|
|
|
235
238
|
* @reference https://developer.themoviedb.org/reference/movie-translations
|
|
236
239
|
*/
|
|
237
240
|
async translations(params) {
|
|
238
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.TRANSLATIONS}`;
|
|
241
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.TRANSLATIONS}`;
|
|
239
242
|
return this.client.request(endpoint);
|
|
240
243
|
}
|
|
241
244
|
/**
|
|
@@ -249,7 +252,7 @@ export class MoviesAPI {
|
|
|
249
252
|
*/
|
|
250
253
|
async videos(params) {
|
|
251
254
|
const { language = this.defaultOptions.language, ...rest } = params;
|
|
252
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.VIDEOS}`;
|
|
255
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.VIDEOS}`;
|
|
253
256
|
return this.client.request(endpoint, { language, ...rest });
|
|
254
257
|
}
|
|
255
258
|
/**
|
|
@@ -269,7 +272,8 @@ export class MoviesAPI {
|
|
|
269
272
|
* @reference https://developer.themoviedb.org/reference/movie-videos
|
|
270
273
|
*/
|
|
271
274
|
async watch_providers(params) {
|
|
272
|
-
const endpoint = `${MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${MOVIE_ENDPOINTS.WATCH_PROVIDERS}`;
|
|
275
|
+
const endpoint = `${exports.MOVIE_ENDPOINTS.MOVIE}/${params.movie_id}${exports.MOVIE_ENDPOINTS.WATCH_PROVIDERS}`;
|
|
273
276
|
return this.client.request(endpoint);
|
|
274
277
|
}
|
|
275
278
|
}
|
|
279
|
+
exports.MoviesAPI = MoviesAPI;
|
package/dist/endpoints/search.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchAPI = exports.SEARCH_ENDPOINTS = void 0;
|
|
4
|
+
exports.SEARCH_ENDPOINTS = {
|
|
2
5
|
MOVIE: "/search/movie",
|
|
3
6
|
};
|
|
4
|
-
|
|
7
|
+
class SearchAPI {
|
|
5
8
|
client;
|
|
6
9
|
defaultOptions; // ** Default options for all requests
|
|
7
10
|
constructor(client, defaultOptions = {}) {
|
|
@@ -27,7 +30,8 @@ export class SearchAPI {
|
|
|
27
30
|
* @reference https://developer.themoviedb.org/reference/search-movie
|
|
28
31
|
*/
|
|
29
32
|
async movies(params) {
|
|
30
|
-
const endpoint = `${SEARCH_ENDPOINTS.MOVIE}`;
|
|
33
|
+
const endpoint = `${exports.SEARCH_ENDPOINTS.MOVIE}`;
|
|
31
34
|
return this.client.request(endpoint, this.withDefaults(params));
|
|
32
35
|
}
|
|
33
36
|
}
|
|
37
|
+
exports.SearchAPI = SearchAPI;
|
package/dist/errors/messages.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TMDB_ERRORS = exports.Errors = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* A collection of error messages used throughout the application.
|
|
3
6
|
* For library-specific errors (-1 status code) only.
|
|
4
7
|
*/
|
|
5
|
-
|
|
8
|
+
exports.Errors = {
|
|
6
9
|
NO_ACCESS_TOKEN: "TMDB requires a valid access token, please provide one.",
|
|
7
10
|
};
|
|
8
11
|
/**
|
|
9
12
|
* TMDB Error Codes and messages.
|
|
10
13
|
* @reference https://developer.themoviedb.org/docs/errors
|
|
11
14
|
*/
|
|
12
|
-
|
|
15
|
+
exports.TMDB_ERRORS = new Map([
|
|
13
16
|
[1, { message: "Success", http_status: 200 }],
|
|
14
17
|
[2, { message: "Invalid service: this service does not exist.", http_status: 501 }],
|
|
15
18
|
[3, { message: "Authentication failed: You do not have permissions to access the service.", http_status: 401 }],
|
package/dist/errors/tmdb.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TMDBError = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Represents a generic error or an error specific to the TMDB (The Movie Database) API.
|
|
3
6
|
* This error class extends the built-in `Error` class and includes additional
|
|
4
7
|
* properties to provide more context about the error.
|
|
5
8
|
*/
|
|
6
|
-
|
|
9
|
+
class TMDBError extends Error {
|
|
7
10
|
/**
|
|
8
11
|
* The status code returned by the TMDB API.
|
|
9
12
|
* If the value is `-1`, it indicates a library-specific error rather than a TMDB API error.
|
|
@@ -37,3 +40,4 @@ export class TMDBError extends Error {
|
|
|
37
40
|
this.http_status_code = http_status;
|
|
38
41
|
}
|
|
39
42
|
}
|
|
43
|
+
exports.TMDBError = TMDBError;
|
package/dist/images/images.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageAPI = void 0;
|
|
4
|
+
const images_1 = require("../types/images");
|
|
5
|
+
class ImageAPI {
|
|
3
6
|
options;
|
|
4
7
|
constructor(options = {}) {
|
|
5
8
|
this.options = { secure_images_url: true, ...options };
|
|
6
9
|
}
|
|
7
10
|
buildUrl(path, size) {
|
|
8
|
-
const baseUrl = this.options.secure_images_url ? IMAGE_SECURE_BASE_URL : IMAGE_BASE_URL;
|
|
11
|
+
const baseUrl = this.options.secure_images_url ? images_1.IMAGE_SECURE_BASE_URL : images_1.IMAGE_BASE_URL;
|
|
9
12
|
return `${baseUrl}${size}${path}`;
|
|
10
13
|
}
|
|
11
14
|
backdrop(path, size = this.options.default_image_sizes?.backdrops || "w780") {
|
|
@@ -24,3 +27,4 @@ export class ImageAPI {
|
|
|
24
27
|
return this.buildUrl(path, size);
|
|
25
28
|
}
|
|
26
29
|
}
|
|
30
|
+
exports.ImageAPI = ImageAPI;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.TMDBError = exports.TMDB = void 0;
|
|
1
18
|
// src/index.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
19
|
+
var tmdb_1 = require("./tmdb");
|
|
20
|
+
Object.defineProperty(exports, "TMDB", { enumerable: true, get: function () { return tmdb_1.TMDB; } });
|
|
21
|
+
var tmdb_2 = require("./errors/tmdb");
|
|
22
|
+
Object.defineProperty(exports, "TMDBError", { enumerable: true, get: function () { return tmdb_2.TMDBError; } });
|
|
23
|
+
__exportStar(require("./types"), exports);
|
package/dist/tmdb.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// src.tmdb.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TMDB = void 0;
|
|
5
|
+
const client_1 = require("./client");
|
|
6
|
+
const movie_lists_1 = require("./endpoints/movie_lists");
|
|
7
|
+
const movies_1 = require("./endpoints/movies");
|
|
8
|
+
const search_1 = require("./endpoints/search");
|
|
9
|
+
const messages_1 = require("./errors/messages");
|
|
10
|
+
const images_1 = require("./images/images");
|
|
11
|
+
class TMDB {
|
|
9
12
|
client;
|
|
10
13
|
options; // ** Default options for all requests
|
|
11
14
|
movies;
|
|
@@ -20,12 +23,13 @@ export class TMDB {
|
|
|
20
23
|
*/
|
|
21
24
|
constructor(accessToken, options = {}) {
|
|
22
25
|
if (!accessToken)
|
|
23
|
-
throw new Error(Errors.NO_ACCESS_TOKEN);
|
|
26
|
+
throw new Error(messages_1.Errors.NO_ACCESS_TOKEN);
|
|
24
27
|
this.options = options;
|
|
25
|
-
this.client = new ApiClient(accessToken);
|
|
26
|
-
this.movies = new MoviesAPI(this.client, this.options);
|
|
27
|
-
this.movie_lists = new MovieListsAPI(this.client, this.options);
|
|
28
|
-
this.search = new SearchAPI(this.client, this.options);
|
|
29
|
-
this.images = new ImageAPI(this.options.images);
|
|
28
|
+
this.client = new client_1.ApiClient(accessToken);
|
|
29
|
+
this.movies = new movies_1.MoviesAPI(this.client, this.options);
|
|
30
|
+
this.movie_lists = new movie_lists_1.MovieListsAPI(this.client, this.options);
|
|
31
|
+
this.search = new search_1.SearchAPI(this.client, this.options);
|
|
32
|
+
this.images = new images_1.ImageAPI(this.options.images);
|
|
30
33
|
}
|
|
31
34
|
}
|
|
35
|
+
exports.TMDB = TMDB;
|
package/dist/types/common.js
CHANGED
package/dist/types/countries.js
CHANGED
package/dist/types/enums.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReleaseType = void 0;
|
|
4
|
+
var ReleaseType;
|
|
2
5
|
(function (ReleaseType) {
|
|
3
6
|
ReleaseType[ReleaseType["Premiere"] = 1] = "Premiere";
|
|
4
7
|
ReleaseType[ReleaseType["TheatricalLimited"] = 2] = "TheatricalLimited";
|
|
@@ -6,4 +9,4 @@ export var ReleaseType;
|
|
|
6
9
|
ReleaseType[ReleaseType["Digital"] = 4] = "Digital";
|
|
7
10
|
ReleaseType[ReleaseType["Physical"] = 5] = "Physical";
|
|
8
11
|
ReleaseType[ReleaseType["TV"] = 6] = "TV";
|
|
9
|
-
})(ReleaseType || (ReleaseType = {}));
|
|
12
|
+
})(ReleaseType || (exports.ReleaseType = ReleaseType = {}));
|
package/dist/types/images.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STILL_SIZES = exports.PROFILE_SIZES = exports.POSTER_SIZES = exports.LOGO_SIZES = exports.BACKDROP_SIZES = exports.IMAGE_SECURE_BASE_URL = exports.IMAGE_BASE_URL = void 0;
|
|
1
4
|
// Image base URLs
|
|
2
|
-
|
|
3
|
-
|
|
5
|
+
exports.IMAGE_BASE_URL = "http://image.tmdb.org/t/p/";
|
|
6
|
+
exports.IMAGE_SECURE_BASE_URL = "https://image.tmdb.org/t/p/";
|
|
4
7
|
// Backdrop sizes
|
|
5
|
-
|
|
8
|
+
exports.BACKDROP_SIZES = ["w300", "w780", "w1280", "original"];
|
|
6
9
|
// Logo sizes
|
|
7
|
-
|
|
10
|
+
exports.LOGO_SIZES = ["w45", "w92", "w154", "w185", "w300", "w500", "original"];
|
|
8
11
|
// Poster sizes
|
|
9
|
-
|
|
12
|
+
exports.POSTER_SIZES = ["w92", "w154", "w185", "w342", "w500", "w780", "original"];
|
|
10
13
|
// Profile sizes
|
|
11
|
-
|
|
14
|
+
exports.PROFILE_SIZES = ["w45", "w185", "h632", "original"];
|
|
12
15
|
// Still sizes
|
|
13
|
-
|
|
16
|
+
exports.STILL_SIZES = ["w92", "w185", "w300", "original"];
|
package/dist/types/index.js
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./common"), exports);
|
|
18
|
+
__exportStar(require("./countries"), exports);
|
|
19
|
+
__exportStar(require("./enums"), exports);
|
|
20
|
+
__exportStar(require("./lang"), exports);
|
|
21
|
+
__exportStar(require("./movies"), exports);
|
|
22
|
+
__exportStar(require("./params"), exports);
|
|
23
|
+
__exportStar(require("./utility"), exports);
|
|
24
|
+
__exportStar(require("./images"), exports);
|
package/dist/types/intl.d.ts
CHANGED
package/dist/types/intl.js
CHANGED
package/dist/types/lang.js
CHANGED
package/dist/types/movies.js
CHANGED
package/dist/types/params.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/types/utility.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/package.json
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lorenzopant/tmdb",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A completely type-safe The Movie Database (TMDB) API wrapper for typescript applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/lorenzopant/tmdb"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"build:watch": "tsc --watch",
|
|
14
|
+
"test": "vitest",
|
|
15
|
+
"test:ui": "vitest --ui",
|
|
16
|
+
"test:coverage": "vitest --coverage",
|
|
17
|
+
"prepare": "husky",
|
|
18
|
+
"lint": "eslint .",
|
|
19
|
+
"patch": "npm version patch && npm publish"
|
|
10
20
|
},
|
|
11
21
|
"author": "Lorenzo Pantano",
|
|
12
22
|
"license": "MIT",
|
|
@@ -46,13 +56,5 @@
|
|
|
46
56
|
"types": "./dist/types/index.d.ts",
|
|
47
57
|
"default": "./dist/types/index.js"
|
|
48
58
|
}
|
|
49
|
-
},
|
|
50
|
-
"scripts": {
|
|
51
|
-
"build": "tsc",
|
|
52
|
-
"build:watch": "tsc --watch",
|
|
53
|
-
"test": "vitest",
|
|
54
|
-
"test:ui": "vitest --ui",
|
|
55
|
-
"test:coverage": "vitest --coverage",
|
|
56
|
-
"lint": "eslint ."
|
|
57
59
|
}
|
|
58
|
-
}
|
|
60
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
27
27
|
|
|
28
28
|
/* Modules */
|
|
29
|
-
"module": "
|
|
30
|
-
"rootDir": "src",
|
|
31
|
-
"moduleResolution": "
|
|
29
|
+
"module": "nodenext", /* Specify what module code is generated. */
|
|
30
|
+
"rootDir": "src", /* Specify the root folder within your source files. */
|
|
31
|
+
"moduleResolution": "nodenext", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
32
32
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
33
33
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
34
34
|
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"images.test.d.ts","sourceRoot":"","sources":["../../../src/tests/images/images.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { IMAGE_SECURE_BASE_URL, IMAGE_BASE_URL } from "../../types/images";
|
|
3
|
-
import { ImageAPI } from "../../images/images";
|
|
4
|
-
describe("ImageAPI", () => {
|
|
5
|
-
const path = "/sample.jpg";
|
|
6
|
-
test("should generate secure poster URL by default", () => {
|
|
7
|
-
const imageAPI = new ImageAPI();
|
|
8
|
-
const poster_path = "/1E5baAaEse26fej7uHcjOgEE2t2.jpg"; // Fast X
|
|
9
|
-
const url = imageAPI.poster(poster_path);
|
|
10
|
-
expect(url).toBe(`${IMAGE_SECURE_BASE_URL}w500${poster_path}`);
|
|
11
|
-
});
|
|
12
|
-
test("should generate non-secure poster URL when configured", () => {
|
|
13
|
-
const poster_path = "/1E5baAaEse26fej7uHcjOgEE2t2.jpg"; // Fast X
|
|
14
|
-
const imageAPI = new ImageAPI({ secure_images_url: false });
|
|
15
|
-
const url = imageAPI.poster(poster_path);
|
|
16
|
-
expect(url).toBe(`${IMAGE_BASE_URL}w500${poster_path}`);
|
|
17
|
-
});
|
|
18
|
-
test("should use default image sizes if defined", () => {
|
|
19
|
-
const imageAPI = new ImageAPI({ default_image_sizes: { posters: "original" } });
|
|
20
|
-
const url = imageAPI.poster(path);
|
|
21
|
-
expect(url).toBe(`${IMAGE_SECURE_BASE_URL}original${path}`);
|
|
22
|
-
});
|
|
23
|
-
test("should generate backdrop URL", () => {
|
|
24
|
-
const imageAPI = new ImageAPI();
|
|
25
|
-
const url = imageAPI.backdrop(path, "w1280");
|
|
26
|
-
expect(url).toBe(`${IMAGE_SECURE_BASE_URL}w1280${path}`);
|
|
27
|
-
});
|
|
28
|
-
test("should generate logo URL", () => {
|
|
29
|
-
const imageAPI = new ImageAPI();
|
|
30
|
-
const url = imageAPI.logo(path, "w300");
|
|
31
|
-
expect(url).toBe(`${IMAGE_SECURE_BASE_URL}w300${path}`);
|
|
32
|
-
});
|
|
33
|
-
test("should generate profile URL", () => {
|
|
34
|
-
const imageAPI = new ImageAPI();
|
|
35
|
-
const url = imageAPI.profile(path, "h632");
|
|
36
|
-
expect(url).toBe(`${IMAGE_SECURE_BASE_URL}h632${path}`);
|
|
37
|
-
});
|
|
38
|
-
test("should generate still URL", () => {
|
|
39
|
-
const imageAPI = new ImageAPI();
|
|
40
|
-
const url = imageAPI.still(path, "w300");
|
|
41
|
-
expect(url).toBe(`${IMAGE_SECURE_BASE_URL}w300${path}`);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"movie_list.integration.test.d.ts","sourceRoot":"","sources":["../../../src/tests/movie_list/movie_list.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { TMDB } from "../../tmdb";
|
|
3
|
-
const token = process.env.TMDB_ACCESS_TOKEN;
|
|
4
|
-
if (!token)
|
|
5
|
-
throw new Error("TMDB_ACCESS_TOKEN is not set, plaase set it in your enviroment variables.");
|
|
6
|
-
const tmdb = new TMDB(token, { language: "it", region: "IT" });
|
|
7
|
-
describe("Movie List (integration)", () => {
|
|
8
|
-
it("(NOW PLAYING) should get now playing movies", async () => {
|
|
9
|
-
const now_playing = await tmdb.movie_lists.now_playing();
|
|
10
|
-
expect(now_playing.page).toBe(1);
|
|
11
|
-
expect(now_playing.total_results).toBeGreaterThan(0);
|
|
12
|
-
expect(now_playing.results.length).toBeGreaterThan(0);
|
|
13
|
-
});
|
|
14
|
-
it("(POPULAR) should get popular movies", async () => {
|
|
15
|
-
const popular = await tmdb.movie_lists.popular();
|
|
16
|
-
expect(popular.page).toBe(1);
|
|
17
|
-
expect(popular.total_results).toBeGreaterThan(0);
|
|
18
|
-
expect(popular.results.length).toBeGreaterThan(0);
|
|
19
|
-
});
|
|
20
|
-
it("(TOP RATED) should get top rated movies", async () => {
|
|
21
|
-
const top_rated = await tmdb.movie_lists.top_rated();
|
|
22
|
-
expect(top_rated.page).toBe(1);
|
|
23
|
-
expect(top_rated.total_results).toBeGreaterThan(0);
|
|
24
|
-
expect(top_rated.results.length).toBeGreaterThan(0);
|
|
25
|
-
});
|
|
26
|
-
it("(UPCOMING) should get upcoming movies", async () => {
|
|
27
|
-
const upcoming = await tmdb.movie_lists.upcoming();
|
|
28
|
-
expect(upcoming.page).toBe(1);
|
|
29
|
-
expect(upcoming.total_results).toBeGreaterThan(0);
|
|
30
|
-
expect(upcoming.results.length).toBeGreaterThan(0);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"movies.integration.test.d.ts","sourceRoot":"","sources":["../../../src/tests/movies/movies.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { TMDBError } from "../../errors/tmdb";
|
|
3
|
-
import { TMDB } from "../../tmdb";
|
|
4
|
-
const token = process.env.TMDB_ACCESS_TOKEN;
|
|
5
|
-
if (!token)
|
|
6
|
-
throw new Error("TMDB_ACCESS_TOKEN is not set, plaase set it in your enviroment variables.");
|
|
7
|
-
const tmdb = new TMDB(token);
|
|
8
|
-
describe("Movies (integration)", () => {
|
|
9
|
-
it("(MOVIE DETAILS) should get movie details", async () => {
|
|
10
|
-
const movie_id = 550; // Fight Club
|
|
11
|
-
const movie = await tmdb.movies.details({ movie_id });
|
|
12
|
-
expect(movie).toBeDefined();
|
|
13
|
-
expect(movie.id).toBe(movie_id);
|
|
14
|
-
expect(movie.title).toBe("Fight Club");
|
|
15
|
-
});
|
|
16
|
-
it("(MOVIE DETAILS) should throw an error for not found movie ID", async () => {
|
|
17
|
-
const invalid_movie_id = -1; // Invalid movie ID
|
|
18
|
-
// ** Can't test the specific error because API is not returning the same error for the same request
|
|
19
|
-
try {
|
|
20
|
-
await tmdb.movies.details({ movie_id: invalid_movie_id });
|
|
21
|
-
throw new Error("Expected TMDBError was not thrown");
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
expect(error).toBeInstanceOf(TMDBError);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
it("(MOVIE DETAILS) should get movie details with appended response", async () => {
|
|
28
|
-
const movie_id = 550; // Fight Club
|
|
29
|
-
const movie = await tmdb.movies.details({ movie_id, append_to_response: ["reviews"] });
|
|
30
|
-
expect(movie).toBeDefined();
|
|
31
|
-
expect(movie.id).toBe(movie_id);
|
|
32
|
-
expect(movie.title).toBe("Fight Club");
|
|
33
|
-
expect(movie.reviews.results).toBeDefined();
|
|
34
|
-
expect(movie.reviews.results.length).toBeGreaterThanOrEqual(0);
|
|
35
|
-
});
|
|
36
|
-
it("(MOVIE ALTERNATIVE TITLES) should get movie alternative titles", async () => {
|
|
37
|
-
const movie_id = 550; // Fight Club
|
|
38
|
-
const movie_titles = await tmdb.movies.alternative_titles({ movie_id });
|
|
39
|
-
expect(movie_titles).toBeDefined();
|
|
40
|
-
expect(movie_titles.id).toBe(movie_id);
|
|
41
|
-
expect(movie_titles.titles.length).toBeGreaterThan(0);
|
|
42
|
-
});
|
|
43
|
-
it("(MOVIE CREDITS) should get movie credits", async () => {
|
|
44
|
-
const movie_id = 550; // Fight Club
|
|
45
|
-
const credits = await tmdb.movies.credits({ movie_id });
|
|
46
|
-
expect(credits).toBeDefined();
|
|
47
|
-
expect(credits.id).toBe(movie_id);
|
|
48
|
-
expect(credits.cast.length).toBeGreaterThan(0);
|
|
49
|
-
expect(credits.crew.length).toBeGreaterThan(0);
|
|
50
|
-
expect(credits.cast[0].name).toBe("Edward Norton");
|
|
51
|
-
});
|
|
52
|
-
it("(MOVIE EXTERNAL IDS) should get movie external IDs", async () => {
|
|
53
|
-
const movie_id = 550; // Fight Club
|
|
54
|
-
const external_ids = await tmdb.movies.external_ids({ movie_id });
|
|
55
|
-
expect(external_ids).toBeDefined();
|
|
56
|
-
expect(external_ids.id).toBe(movie_id);
|
|
57
|
-
expect(external_ids.imdb_id).toBe("tt0137523");
|
|
58
|
-
});
|
|
59
|
-
it("(MOVIE KEYWORDS) should get movie keywords", async () => {
|
|
60
|
-
const movie_id = 550; // Fight Club
|
|
61
|
-
const keywords = await tmdb.movies.keywords({ movie_id });
|
|
62
|
-
expect(keywords).toBeDefined();
|
|
63
|
-
expect(keywords.id).toBe(movie_id);
|
|
64
|
-
expect(keywords.keywords.length).toBeGreaterThan(0);
|
|
65
|
-
});
|
|
66
|
-
it("(MOVIE CHANGES) should get movie changes", async () => {
|
|
67
|
-
const movie_id = 550; // Fight Club
|
|
68
|
-
const start_date = "2024-12-20";
|
|
69
|
-
const end_date = "2024-12-24";
|
|
70
|
-
const changes = await tmdb.movies.changes({ movie_id, start_date, end_date });
|
|
71
|
-
expect(changes).toBeDefined();
|
|
72
|
-
expect(changes.changes).toBeDefined();
|
|
73
|
-
expect(changes.changes[0].key).toBe("images");
|
|
74
|
-
expect(changes.changes[0].items.length).toBeGreaterThan(0);
|
|
75
|
-
});
|
|
76
|
-
it("(MOVIE IMAGES) should get movie images", async () => {
|
|
77
|
-
const movie_id = 550; // Fight Club
|
|
78
|
-
const images = await tmdb.movies.images({ movie_id });
|
|
79
|
-
expect(images).toBeDefined();
|
|
80
|
-
expect(images.id).toBe(movie_id);
|
|
81
|
-
expect(images.backdrops.length).toBeGreaterThan(0);
|
|
82
|
-
expect(images.posters.length).toBeGreaterThan(0);
|
|
83
|
-
});
|
|
84
|
-
it("(MOVIE IMAGES) should get movie images for a specific language", async () => {
|
|
85
|
-
const movie_id = 550; // Fight Club
|
|
86
|
-
const images = await tmdb.movies.images({ movie_id, language: "de" });
|
|
87
|
-
expect(images).toBeDefined();
|
|
88
|
-
expect(images.id).toBe(movie_id);
|
|
89
|
-
expect(images.backdrops.length).toBeGreaterThanOrEqual(0);
|
|
90
|
-
expect(images.posters.length).toBeGreaterThan(0);
|
|
91
|
-
});
|
|
92
|
-
it("(MOVIE LATEST) should get the latest movie details", async () => {
|
|
93
|
-
const latestMovie = await tmdb.movies.latest();
|
|
94
|
-
expect(latestMovie).toBeDefined();
|
|
95
|
-
expect(latestMovie.id).toBeDefined();
|
|
96
|
-
expect(latestMovie.title).toBeDefined();
|
|
97
|
-
});
|
|
98
|
-
it("(MOVIE RECOMMENDATIONS) should get movie recommendations", async () => {
|
|
99
|
-
const movie_id = 550; // Fight Club
|
|
100
|
-
const recommendations = await tmdb.movies.recommendations({ movie_id });
|
|
101
|
-
expect(recommendations).toBeDefined();
|
|
102
|
-
expect(recommendations.results.length).toBeGreaterThan(0);
|
|
103
|
-
expect(recommendations.results[0].id).toBeDefined();
|
|
104
|
-
expect(recommendations.page).toBe(1);
|
|
105
|
-
expect(recommendations.total_results).toBeGreaterThan(0);
|
|
106
|
-
expect(recommendations.total_pages).toBeGreaterThan(0);
|
|
107
|
-
});
|
|
108
|
-
it("(MOVIE RELEASE DATES) should get movie release dates", async () => {
|
|
109
|
-
const movie_id = 550; // Fight Club
|
|
110
|
-
const release_dates = await tmdb.movies.release_dates({ movie_id });
|
|
111
|
-
expect(release_dates).toBeDefined();
|
|
112
|
-
expect(release_dates.id).toBe(movie_id);
|
|
113
|
-
expect(release_dates.results.length).toBeGreaterThan(0);
|
|
114
|
-
expect(release_dates.results[0].iso_3166_1).toBeDefined();
|
|
115
|
-
expect(release_dates.results[0].release_dates.length).toBeGreaterThan(0);
|
|
116
|
-
});
|
|
117
|
-
it("(MOVIE REVIEWS) should get movie reviews", async () => {
|
|
118
|
-
const movie_id = 550; // Fight Club
|
|
119
|
-
const reviews = await tmdb.movies.reviews({ movie_id });
|
|
120
|
-
expect(reviews).toBeDefined();
|
|
121
|
-
expect(reviews.results.length).toBeGreaterThan(0);
|
|
122
|
-
expect(reviews.results[0].id).toBeDefined();
|
|
123
|
-
expect(reviews.page).toBe(1);
|
|
124
|
-
expect(reviews.total_results).toBeGreaterThan(0);
|
|
125
|
-
expect(reviews.total_pages).toBeGreaterThan(0);
|
|
126
|
-
});
|
|
127
|
-
it("(MOVIE SIMILAR) should get similar movies", async () => {
|
|
128
|
-
const movie_id = 550;
|
|
129
|
-
const similar = await tmdb.movies.similar({ movie_id });
|
|
130
|
-
expect(similar).toBeDefined();
|
|
131
|
-
expect(similar.results.length).toBeGreaterThan(0);
|
|
132
|
-
expect(similar.results[0].id).toBeDefined();
|
|
133
|
-
expect(similar.page).toBe(1);
|
|
134
|
-
expect(similar.total_results).toBeGreaterThan(0);
|
|
135
|
-
expect(similar.total_pages).toBeGreaterThan(0);
|
|
136
|
-
});
|
|
137
|
-
it("(MOVIE TRANSLATIONS) should get translations for a movie", async () => {
|
|
138
|
-
const movie_id = 550;
|
|
139
|
-
const translations = await tmdb.movies.translations({ movie_id });
|
|
140
|
-
expect(translations).toBeDefined();
|
|
141
|
-
expect(translations.id).toBe(movie_id);
|
|
142
|
-
expect(translations.translations).toBeDefined();
|
|
143
|
-
expect(translations.translations.length).toBeGreaterThan(0);
|
|
144
|
-
expect(translations.translations[0].data).toBeDefined();
|
|
145
|
-
});
|
|
146
|
-
it("(MOVIE VIDEOS) should get videos for a movie", async () => {
|
|
147
|
-
const movie_id = 550;
|
|
148
|
-
const videos = await tmdb.movies.videos({ movie_id });
|
|
149
|
-
expect(videos).toBeDefined();
|
|
150
|
-
expect(videos.id).toBe(movie_id);
|
|
151
|
-
expect(videos.results).toBeDefined();
|
|
152
|
-
expect(videos.results.length).toBeGreaterThan(0);
|
|
153
|
-
expect(videos.results[0].id).toBeDefined();
|
|
154
|
-
});
|
|
155
|
-
it("(MOVIE WATCH PROVIDERS) should get watch providers for a movie", async () => {
|
|
156
|
-
const movie_id = 550;
|
|
157
|
-
const watch_providers = await tmdb.movies.watch_providers({ movie_id });
|
|
158
|
-
expect(watch_providers).toBeDefined();
|
|
159
|
-
expect(watch_providers.id).toBe(movie_id);
|
|
160
|
-
expect(watch_providers.results).toBeDefined();
|
|
161
|
-
expect(watch_providers.results["US"]).toBeDefined();
|
|
162
|
-
});
|
|
163
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"movies.test.d.ts","sourceRoot":"","sources":["../../../src/tests/movies/movies.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { ApiClient } from "../../client";
|
|
3
|
-
import { MoviesAPI } from "../../endpoints/movies";
|
|
4
|
-
describe("MoviesAPI", () => {
|
|
5
|
-
let clientMock;
|
|
6
|
-
let moviesAPI;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
clientMock = new ApiClient("valid_access_token");
|
|
9
|
-
clientMock.request = vi.fn();
|
|
10
|
-
moviesAPI = new MoviesAPI(clientMock);
|
|
11
|
-
});
|
|
12
|
-
it("should call client.request with the correct parameters", async () => {
|
|
13
|
-
const movie_id = 550;
|
|
14
|
-
const language = "en";
|
|
15
|
-
const append_to_response = ["credits", "images"];
|
|
16
|
-
await moviesAPI.details({ movie_id, language, append_to_response });
|
|
17
|
-
expect(clientMock.request).toHaveBeenCalledOnce();
|
|
18
|
-
expect(clientMock.request).toHaveBeenCalledWith("/movie/550", {
|
|
19
|
-
movie_id,
|
|
20
|
-
append_to_response,
|
|
21
|
-
language,
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
it("should work correctly without optional parameters", async () => {
|
|
25
|
-
const movie_id = 550;
|
|
26
|
-
await moviesAPI.details({ movie_id });
|
|
27
|
-
expect(clientMock.request).toHaveBeenCalledOnce();
|
|
28
|
-
expect(clientMock.request).toHaveBeenCalledWith("/movie/550", {
|
|
29
|
-
movie_id,
|
|
30
|
-
append_to_response: undefined,
|
|
31
|
-
language: undefined,
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
it("should return the result from client.request", async () => {
|
|
35
|
-
const fakeResponse = { id: 550, title: "Fight Club" };
|
|
36
|
-
clientMock.request.mockResolvedValue(fakeResponse);
|
|
37
|
-
const result = await moviesAPI.details({ movie_id: 550 });
|
|
38
|
-
expect(result).toEqual(fakeResponse);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search.integration.test.d.ts","sourceRoot":"","sources":["../../../src/tests/search/search.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { TMDB } from "../../tmdb";
|
|
3
|
-
const token = process.env.TMDB_ACCESS_TOKEN;
|
|
4
|
-
if (!token)
|
|
5
|
-
throw new Error("TMDB_ACCESS_TOKEN is not set, plaase set it in your enviroment variables.");
|
|
6
|
-
const tmdb = new TMDB(token);
|
|
7
|
-
describe("Search (integration)", () => {
|
|
8
|
-
it("(SEARCH MOVIE) should search for a particular movie", async () => {
|
|
9
|
-
const movies = await tmdb.search.movies({ query: "Fight Club" });
|
|
10
|
-
expect(movies.page).toBe(1);
|
|
11
|
-
expect(movies.total_results).toBeGreaterThan(0);
|
|
12
|
-
expect(movies.results.length).toBeGreaterThan(0);
|
|
13
|
-
expect(movies.results[0].title).toBe("Fight Club");
|
|
14
|
-
});
|
|
15
|
-
it("(SEARCH MOVIE) should search for a movie with default options", async () => {
|
|
16
|
-
const tmdb = new TMDB(token, { language: "it", region: "IT" });
|
|
17
|
-
const movies = await tmdb.search.movies({ query: "Fight Club" });
|
|
18
|
-
expect(movies.page).toBe(1);
|
|
19
|
-
expect(movies.total_results).toBeGreaterThan(0);
|
|
20
|
-
expect(movies.results.length).toBeGreaterThan(0);
|
|
21
|
-
expect(movies.results[0].title).toBe("Fight Club");
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tmdb.test.d.ts","sourceRoot":"","sources":["../../src/tests/tmdb.test.ts"],"names":[],"mappings":""}
|
package/dist/tests/tmdb.test.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { TMDB } from "../tmdb";
|
|
3
|
-
import { Errors } from "../errors/messages";
|
|
4
|
-
describe("TMDB API Client", () => {
|
|
5
|
-
it("should throw an error if no access token is provided", () => {
|
|
6
|
-
expect(() => new TMDB("")).toThrowError(Errors.NO_ACCESS_TOKEN);
|
|
7
|
-
});
|
|
8
|
-
it("should create an instance of TMDB with a valid access token", () => {
|
|
9
|
-
const tmdb = new TMDB("valid_access_token");
|
|
10
|
-
expect(tmdb).toBeInstanceOf(TMDB);
|
|
11
|
-
});
|
|
12
|
-
});
|