Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
dd153b8
[fix] move API to parent folder
matfire Feb 22, 2022
b7aa359
[add] pre-push hook added
matfire Feb 22, 2022
bb97583
[add] movie test suite
matfire Feb 22, 2022
d8756ae
[add] movie service
matfire Feb 22, 2022
b8a1f4c
[fix] import fix
matfire Feb 22, 2022
ef3bba9
[del] removed package-lock
matfire Feb 22, 2022
0c5986c
[add] added package-lock
matfire Feb 22, 2022
c9f703a
[wip] fixing workflow
matfire Feb 22, 2022
b2d66a0
[wip] fixing workflow
matfire Feb 22, 2022
72359a6
[wip] fixing workflow
matfire Feb 22, 2022
90d1d47
[wip] fixing workflow
matfire Feb 22, 2022
9881dfb
[wip] fixing workflow
matfire Feb 22, 2022
4f7d634
[wip] fixing workflow
matfire Feb 22, 2022
2101394
[wip] movie service not overriding params
matfire Feb 22, 2022
688758c
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
5763abe
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
e01b670
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
498fd07
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
f44f320
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
8e9d381
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
bac7a1f
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
87284ae
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
09edf34
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
a69b3a4
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
4e7d8b6
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
f13b38f
[wip] parameter mergin in axios requests
matfire Feb 23, 2022
4950dec
[wip] parameter mergin in axios requests
matfire Feb 23, 2022
248986a
[wip] parameter mergin in axios requests
matfire Feb 23, 2022
66ad703
[wip] parameter mergin in axios requests
matfire Feb 23, 2022
a2728df
[wip] parameter mergin in axios requests
matfire Feb 23, 2022
1544eed
[test] check for model value
matfire Feb 23, 2022
8fca382
[del] removed debug statement
matfire Feb 23, 2022
6383ec5
[mod] simplified fromJson factory
matfire Feb 23, 2022
1bd2e6b
[add] movie search + tests + language selection
matfire Feb 23, 2022
a971782
[wip] get single movie - no extra request for now
matfire Feb 23, 2022
cacaf12
[add] updating package-lock
matfire Feb 23, 2022
c418a76
[add] get latest movie feature
matfire Feb 24, 2022
f668670
[add] get now_playing
matfire Feb 24, 2022
b96013a
[add] get now_playing
matfire Feb 24, 2022
85075a4
[add] docs directory and README rewrite
matfire Feb 28, 2022
2d44832
[fix] small fixes
matfire Mar 1, 2022
a260499
Merge pull request #5 from matfire/feature/documentation
matfire Mar 1, 2022
3b1d685
[fix] move API to parent folder
matfire Feb 22, 2022
dbb1def
[add] pre-push hook added
matfire Feb 22, 2022
f3bbdfe
[add] movie test suite
matfire Feb 22, 2022
2954aac
[add] movie service
matfire Feb 22, 2022
499262a
[fix] import fix
matfire Feb 22, 2022
092d577
[del] removed package-lock
matfire Feb 22, 2022
3193c05
[add] added package-lock
matfire Feb 22, 2022
a8c4fb2
[wip] fixing workflow
matfire Feb 22, 2022
03a032d
[wip] fixing workflow
matfire Feb 22, 2022
3028a2b
[wip] fixing workflow
matfire Feb 22, 2022
d535c93
[wip] fixing workflow
matfire Feb 22, 2022
369d783
[wip] fixing workflow
matfire Feb 22, 2022
e5dab87
[wip] fixing workflow
matfire Feb 22, 2022
5995302
[wip] movie service not overriding params
matfire Feb 22, 2022
eebf6dd
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
d509fc2
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
323cbaa
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
cfe46b8
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
6d25050
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
018f62c
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
723a9a2
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
e76586c
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
33304d2
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
d40fb98
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
e2a17ef
[wip] parameter mergin in axios requests
matfire Feb 22, 2022
458d2df
[wip] parameter mergin in axios requests
matfire Feb 23, 2022
cb2e6c1
[wip] parameter mergin in axios requests
matfire Feb 23, 2022
b6153d2
[wip] parameter mergin in axios requests
matfire Feb 23, 2022
471101f
[wip] parameter mergin in axios requests
matfire Feb 23, 2022
e5e7a45
[wip] parameter mergin in axios requests
matfire Feb 23, 2022
cf6adf9
[test] check for model value
matfire Feb 23, 2022
b31244a
[del] removed debug statement
matfire Feb 23, 2022
cf9acec
[mod] simplified fromJson factory
matfire Feb 23, 2022
2d9cba7
[add] movie search + tests + language selection
matfire Feb 23, 2022
dce6f72
[wip] get single movie - no extra request for now
matfire Feb 23, 2022
2a9dfcd
[add] updating package-lock
matfire Feb 23, 2022
0e41562
[add] get latest movie feature
matfire Feb 24, 2022
1286ce6
[add] get now_playing
matfire Feb 24, 2022
0187fcd
[add] get now_playing
matfire Feb 24, 2022
e5d9e71
Merge branch 'feature/movieService' of github.com:matfire/TheMovieWra…
matfire Mar 1, 2022
d775173
[add] getAlternativeTitles
matfire Mar 1, 2022
14496cf
[fix] linting
matfire Mar 1, 2022
1cd45cf
[add] movie changes
matfire Mar 3, 2022
e54e043
[fix] linting
matfire Mar 3, 2022
ef3113e
[add] getExternalIds for movie
matfire Mar 4, 2022
b2eb1fa
[fix] changed string to Date in changes
matfire Mar 4, 2022
b68e893
[add] fixing test to also check date
matfire Mar 4, 2022
4859e25
[add] geeric KeywordResult type
matfire Mar 4, 2022
5e536f8
[add] getKeywords for movie details
matfire Mar 4, 2022
6cc8874
[add] getLists for movie details
matfire Mar 4, 2022
584d7b5
[add] get recommendations for movie
matfire Mar 4, 2022
f61817f
[add] get release dates
matfire Mar 4, 2022
115b67b
[add] similar movies for movie
matfire Mar 4, 2022
920a8ad
[add] getTranslations for movie
matfire Mar 5, 2022
a14ab31
[add] getVideos for movies
matfire Mar 8, 2022
00ec210
[add] watch providers for movie
matfire Mar 8, 2022
a5698fe
[add] popular movies
matfire Mar 8, 2022
3d74ed6
[fix] optimizing tests
matfire Mar 8, 2022
f8e669c
[add] topRated movies
matfire Mar 8, 2022
de1d0b2
[add] upcoming movies
matfire Mar 8, 2022
7308865
[add] country codes as enum
matfire Mar 8, 2022
a88cafc
[add] rate, deleteRate + fix type typo
matfire Mar 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ on:
pull_request:
branches: [ master ]

env:
TMDB_KEY: ${{ secrets.TMDB_KEY }}

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -26,8 +29,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
env:
TMDB_KEY: ${{ secrets.TMDB_KEY }}
- run: npm install typescript
- run: npm run build --if-present
- run: npm test
- run: npm test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules/
dist/
lib/
test/
test/
coverage/
.env
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
. "$(dirname "$0")/_/husky.sh"

npm run lint
npm test
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test
27 changes: 1 addition & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,4 @@

---

## Usage

### Install

`npm i @matfire/the_movie_wrapper --save`

### Initialization

there is a single available export in this library.
This export contains the client you'll need to use in order to talk with TMDB's api.

#### Using the client in a projet
```js
import Client from "@matfire/the_movie_wrapper"

const client = new Client("<insert_your_api_key>");
```

### Available Services

Each section of the API has been divided into sections. Taking the code example above, calling the authentication service is done like so: `client.auth.createAuthUrl()`.

#### Authentication
- getAuthenticationToken() -> retrieve an authentication token for user authentication
- createAuthUrl(callbackUrl) -> generates the authentication url where the user should be redirected. Expects a callbackUrl
- createSession(requestToken) -> generates a session_id from a request token
### Documentation
Empty file added docs/.nojekyll
Empty file.
20 changes: 20 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# The Movie Wrapper

## A fully-typed TMDB Api wrapper

---

### Installation and Usage

Check [Quickstart](quickstart.md)

### Available Services

Check [Available Services](services.md)

### Saying thanks

If you liked this library and want to help me repay the coffee debt I created while working on it, you can always
<!-- ko-fi :id=matteogassend :color=red -->
Buy me a coffee
<!-- ko-fi -->
1 change: 1 addition & 0 deletions docs/_404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Nothing to see here
3 changes: 3 additions & 0 deletions docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The Movie Getter

## A fully-typed TMDB wrapper
4 changes: 4 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* [Home](/)
* [Getting Started](quickstart.md)
* [Services](services.md)
* [Authentication](services/authentication.md)
34 changes: 34 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: 'TheMovieGetter',
repo: 'matfire/TheMovieWrapper',
autoHeader: true,
notFoundPage: true,
coverpage: true,
loadSidebar:true
}
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="https://unpkg.com/docsify-copy-code@2"></script>
<script src="//cdn.jsdelivr.net/npm/prismjs@1/components/prism-bash.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-ko-fi"></script>
<script>
if (typeof navigator.serviceWorker !== 'undefined') {
navigator.serviceWorker.register('sw.js')
}
</script>
</body>
</html>
23 changes: 23 additions & 0 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Getting Started

## Installation

in order to install TheMovieGetter, simply run:

```bash
npm install --save @matfire/the-movie-getter
```
from your project directory

## Using the library

- Import the library in your project
```javascript
import Client from "@matfire/the_movie_wrapper"
```
- Initialize the client with your TMDB api key
```javascript
const client = new Client("<insert_your_api_key>");
```

See [Available service](services.md) to learn what is currently available
3 changes: 3 additions & 0 deletions docs/services.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Available Services

- [Authentication](services/authentication.md)
16 changes: 16 additions & 0 deletions docs/services/authentication.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Authentication Service

## Description
this service is responsible for handling authentication. It generates authentication urls against TMDB's website and handles register a `session_id` to the client instance.

## Available Methods

- getAuthenticationToken() : get temporary authentication token
- createAuthUrl(redirectUrl) : generate url for user authentication. If specified, appends redirectUrl to request
- createSession(requestToken) : gets session_id from request token

## Example

```javascript
client.authentication.createAuthUrl('example.com')
```
83 changes: 83 additions & 0 deletions docs/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* ===========================================================
* docsify sw.js
* ===========================================================
* Copyright 2016 @huxpro
* Licensed under Apache 2.0
* Register service worker.
* ========================================================== */

const RUNTIME = 'docsify'
const HOSTNAME_WHITELIST = [
self.location.hostname,
'fonts.gstatic.com',
'fonts.googleapis.com',
'cdn.jsdelivr.net'
]

// The Util Function to hack URLs of intercepted requests
const getFixedUrl = (req) => {
var now = Date.now()
var url = new URL(req.url)

// 1. fixed http URL
// Just keep syncing with location.protocol
// fetch(httpURL) belongs to active mixed content.
// And fetch(httpRequest) is not supported yet.
url.protocol = self.location.protocol

// 2. add query for caching-busting.
// Github Pages served with Cache-Control: max-age=600
// max-age on mutable content is error-prone, with SW life of bugs can even extend.
// Until cache mode of Fetch API landed, we have to workaround cache-busting with query string.
// Cache-Control-Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=453190
if (url.hostname === self.location.hostname) {
url.search += (url.search ? '&' : '?') + 'cache-bust=' + now
}
return url.href
}

/**
* @Lifecycle Activate
* New one activated when old isnt being used.
*
* waitUntil(): activating ====> activated
*/
self.addEventListener('activate', event => {
event.waitUntil(self.clients.claim())
})

/**
* @Functional Fetch
* All network requests are being intercepted here.
*
* void respondWith(Promise<Response> r)
*/
self.addEventListener('fetch', event => {
// Skip some of cross-origin requests, like those for Google Analytics.
if (HOSTNAME_WHITELIST.indexOf(new URL(event.request.url).hostname) > -1) {
// Stale-while-revalidate
// similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale
// Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1
const cached = caches.match(event.request)
const fixedUrl = getFixedUrl(event.request)
const fetched = fetch(fixedUrl, { cache: 'no-store' })
const fetchedCopy = fetched.then(resp => resp.clone())

// Call respondWith() with whatever we get first.
// If the fetch fails (e.g disconnected), wait for the cache.
// If there’s nothing in cache, wait for the fetch.
// If neither yields a response, return offline pages.
event.respondWith(
Promise.race([fetched.catch(_ => cached), cached])
.then(resp => resp || fetched)
.catch(_ => { /* eat any errors */ })
)

// Update the cache with the version we fetched (only for ok status)
event.waitUntil(
Promise.all([fetchedCopy, caches.open(RUNTIME)])
.then(([response, cache]) => response.ok && cache.put(event.request, response))
.catch(_ => { /* eat any errors */ })
)
}
})
Loading