@fennex-sand/services 1.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/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/package.json +26 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Movie } from '@fennex-sand/types';
|
|
2
|
+
export declare function getUrl(apiKey: string, page: number, year?: string, genreId?: number): string;
|
|
3
|
+
export declare const movieService: {
|
|
4
|
+
fetchMovies(url: string): Promise<Movie[]>;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAe5F;AAED,eAAO,MAAM,YAAY;qBACA,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;CAKjD,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ALL, TMDB_BASE_URL } from '@fennex-sand/constants';
|
|
2
|
+
export function getUrl(apiKey, page, year, genreId) {
|
|
3
|
+
let url = `${TMDB_BASE_URL}/discover/movie?api_key=${apiKey}&language=en-US&sort_by=popularity.desc&include_adult=false&include_video=false`;
|
|
4
|
+
if (year && year !== ALL) {
|
|
5
|
+
const yearStart = parseInt(year);
|
|
6
|
+
const yearEnd = yearStart;
|
|
7
|
+
url += `&primary_release_date.gte=${yearStart}-01-01&primary_release_date.lte=${yearEnd}-12-31`;
|
|
8
|
+
}
|
|
9
|
+
if (genreId) {
|
|
10
|
+
url += `&with_genres=${genreId}`;
|
|
11
|
+
}
|
|
12
|
+
url += `&page=${page}`;
|
|
13
|
+
console.log(`====> DEBUG url: `, url, 'page:', page, 'year:', year, 'genreId:', genreId);
|
|
14
|
+
return url;
|
|
15
|
+
}
|
|
16
|
+
export const movieService = {
|
|
17
|
+
async fetchMovies(url) {
|
|
18
|
+
const response = await fetch(url);
|
|
19
|
+
const { results } = await response.json();
|
|
20
|
+
return results;
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,MAAM,UAAU,MAAM,CAAC,MAAc,EAAE,IAAY,EAAE,IAAa,EAAE,OAAgB;IAClF,IAAI,GAAG,GAAG,GAAG,aAAa,2BAA2B,MAAM,iFAAiF,CAAC;IAE7I,IAAI,IAAI,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QACzB,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,SAAS,CAAC;QAC1B,GAAG,IAAI,6BAA6B,SAAS,mCAAmC,OAAO,QAAQ,CAAC;IAClG,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACZ,GAAG,IAAI,gBAAgB,OAAO,EAAE,CAAC;IACnC,CAAC;IAED,GAAG,IAAI,SAAS,IAAI,EAAE,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACzF,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,KAAK,CAAC,WAAW,CAAC,GAAW;QAC3B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC1C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fennex-sand/services",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared services for lynxjs projects",
|
|
5
|
+
"author": "Avraham Hamu",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc -p tsconfig.json",
|
|
15
|
+
"dev": "tsc --watch",
|
|
16
|
+
"clean": "rm -rf dist",
|
|
17
|
+
"deliver": "npm version patch && npm publish --access public"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@fennex/types": "^1.0.0",
|
|
21
|
+
"@fennex/constants": "^1.0.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "~5.8.3"
|
|
25
|
+
}
|
|
26
|
+
}
|