lastfm-nodejs-client 1.0.0 → 1.0.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
- # 1.0.0
1
+ # Changelog
2
+
3
+ ## 1.0.1
4
+
5
+ - Refactors config and methods to own modules
6
+ - tsconfig, generate types to allow shipping types in one package, no need to DefinitleyTyped right now.
7
+ - update docs with new way of interacting with API.
8
+
9
+ ## 1.0.0
2
10
 
3
11
  - Initial project setup
package/README.md CHANGED
@@ -21,9 +21,13 @@ import { lastFm } from 'lastfm-nodejs-client';
21
21
  ### Use it
22
22
 
23
23
  ```js
24
+ const lastFm = LastFmApi();
25
+ const { config } = lastFm;
26
+ const { method } = lastFm;
27
+
24
28
  const getUser = async () => {
25
29
  const data = await lastFm.getInfo(
26
- config.method.user.getInfo,
30
+ method.user.getInfo,
27
31
  config.username,
28
32
  'overall',
29
33
  12
@@ -82,3 +86,9 @@ pnpm build
82
86
  ```bash
83
87
  pnpm test
84
88
  ```
89
+
90
+ ## TODO
91
+
92
+ - [ ] Add types to DefinitelyTyped project
93
+ - [ ] Write tests
94
+ - [ ] Write more endpoints
@@ -0,0 +1,12 @@
1
+ declare const _default: {
2
+ api_key: string;
3
+ app_name: string;
4
+ base_url: string;
5
+ format: {
6
+ json: string;
7
+ xml: string;
8
+ };
9
+ share_secret: string;
10
+ username: string;
11
+ };
12
+ export default _default;
package/dist/config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const config = {
3
+ exports.default = {
4
4
  api_key: `${process.env.LASTFM_API_KEY}`,
5
5
  app_name: `${process.env.LASTFM_APPNAME}`,
6
6
  base_url: `${process.env.LASTFM_API_BASE_URL}`,
@@ -8,22 +8,6 @@ const config = {
8
8
  json: 'json',
9
9
  xml: 'xml',
10
10
  },
11
- method: {
12
- auth: 'auth.getToken',
13
- user: {
14
- getInfo: 'user.getInfo',
15
- loved_tracks: 'user.getLovedTracks',
16
- recent_tracks: 'user.getRecentTracks',
17
- top_albums: 'user.getTopAlbums',
18
- top_artists: 'user.getTopArtists',
19
- top_tracks: 'user.getTopTracks',
20
- weekly_album_chart: 'user.getWeeklyAlbumChart',
21
- weekly_artist_chart: 'user.getWeeklyArtistChart',
22
- weekly_chart_list: 'user.getWeeklyChartList',
23
- weekly_track_chart: 'user.getWeeklyTrackChart',
24
- },
25
- },
26
11
  share_secret: `${process.env.LASTFM_SHARED_SECRET}`,
27
12
  username: `${process.env.LASTFM_USER}`,
28
13
  };
29
- exports.default = config;
@@ -0,0 +1,41 @@
1
+ import { AuthResponse, LovedTracksResponse, RecentTracksResponse, TopAlbumsResponse, TopArtistsResponse, TopTrackResponse, UserResponse, WeeklyAlbumChartResponse, WeeklyArtistChartResponse, WeeklyChartListResponse, WeeklyTrackChartResponse } from './types';
2
+ declare const LastFmApi: () => {
3
+ auth: (method: string, user: string, period: string, limit: number) => Promise<AuthResponse>;
4
+ config: {
5
+ api_key: string;
6
+ app_name: string;
7
+ base_url: string;
8
+ format: {
9
+ json: string;
10
+ xml: string;
11
+ };
12
+ share_secret: string;
13
+ username: string;
14
+ };
15
+ getInfo: (method: string, user: string, period: string, limit: number) => Promise<UserResponse>;
16
+ getLovedTracks: (method: string, user: string, period: string, limit: number) => Promise<LovedTracksResponse>;
17
+ getRecentTracks: (method: string, user: string, period: string, limit: number) => Promise<RecentTracksResponse>;
18
+ getTopAlbums: (method: string, user: string, period: string, limit: number) => Promise<TopAlbumsResponse>;
19
+ getTopArtists: (method: string, user: string, period: string, limit: number) => Promise<TopArtistsResponse>;
20
+ getTopTracks: (method: string, user: string, period: string, limit: number) => Promise<TopTrackResponse>;
21
+ getWeeklyAlbumChart: (method: string, user: string, period: string, limit: number) => Promise<WeeklyAlbumChartResponse>;
22
+ getWeeklyArtistChart: (method: string, user: string, period: string, limit: number) => Promise<WeeklyArtistChartResponse>;
23
+ getWeeklyChartList: (method: string, user: string, period: string, limit: number) => Promise<WeeklyChartListResponse>;
24
+ getWeeklyTrackChart: (method: string, user: string, period: string, limit: number) => Promise<WeeklyTrackChartResponse>;
25
+ method: {
26
+ auth: string;
27
+ user: {
28
+ getInfo: string;
29
+ loved_tracks: string;
30
+ recent_tracks: string;
31
+ top_albums: string;
32
+ top_artists: string;
33
+ top_tracks: string;
34
+ weekly_album_chart: string;
35
+ weekly_artist_chart: string;
36
+ weekly_chart_list: string;
37
+ weekly_track_chart: string;
38
+ };
39
+ };
40
+ };
41
+ export default LastFmApi;
package/dist/index.js CHANGED
@@ -3,6 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const config_1 = __importDefault(require("./config"));
7
+ const method_1 = __importDefault(require("./method"));
6
8
  const request_1 = __importDefault(require("./request"));
7
9
  const LastFmApi = function LastFmApi() {
8
10
  /**
@@ -110,6 +112,7 @@ const LastFmApi = function LastFmApi() {
110
112
  };
111
113
  return {
112
114
  auth,
115
+ config: config_1.default,
113
116
  getInfo,
114
117
  getLovedTracks,
115
118
  getRecentTracks,
@@ -120,6 +123,7 @@ const LastFmApi = function LastFmApi() {
120
123
  getWeeklyArtistChart,
121
124
  getWeeklyChartList,
122
125
  getWeeklyTrackChart,
126
+ method: method_1.default,
123
127
  };
124
128
  };
125
129
  exports.default = LastFmApi;
@@ -0,0 +1,16 @@
1
+ declare const _default: {
2
+ auth: string;
3
+ user: {
4
+ getInfo: string;
5
+ loved_tracks: string;
6
+ recent_tracks: string;
7
+ top_albums: string;
8
+ top_artists: string;
9
+ top_tracks: string;
10
+ weekly_album_chart: string;
11
+ weekly_artist_chart: string;
12
+ weekly_chart_list: string;
13
+ weekly_track_chart: string;
14
+ };
15
+ };
16
+ export default _default;
package/dist/method.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ auth: 'auth.getToken',
5
+ user: {
6
+ getInfo: 'user.getInfo',
7
+ loved_tracks: 'user.getLovedTracks',
8
+ recent_tracks: 'user.getRecentTracks',
9
+ top_albums: 'user.getTopAlbums',
10
+ top_artists: 'user.getTopArtists',
11
+ top_tracks: 'user.getTopTracks',
12
+ weekly_album_chart: 'user.getWeeklyAlbumChart',
13
+ weekly_artist_chart: 'user.getWeeklyArtistChart',
14
+ weekly_chart_list: 'user.getWeeklyChartList',
15
+ weekly_track_chart: 'user.getWeeklyTrackChart',
16
+ },
17
+ };
@@ -0,0 +1,2 @@
1
+ declare const request: <Parameters_1, Response_1>(method: string, user: string, period?: string, limit?: number) => Promise<Response_1>;
2
+ export default request;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lastfm-nodejs-client",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A client for fetching public data with username using the LastFm public API",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -10,9 +10,10 @@
10
10
  },
11
11
  "keywords": [
12
12
  "client",
13
- "lastfm",
13
+ "lastFm",
14
14
  "nodejs",
15
- "typescript"
15
+ "typescript",
16
+ "node"
16
17
  ],
17
18
  "author": "Mannuel Ferreira",
18
19
  "license": "MIT",
package/src/config.ts CHANGED
@@ -1,4 +1,4 @@
1
- const config = {
1
+ export default {
2
2
  api_key: `${process.env.LASTFM_API_KEY}`,
3
3
  app_name: `${process.env.LASTFM_APPNAME}`,
4
4
  base_url: `${process.env.LASTFM_API_BASE_URL}`,
@@ -6,23 +6,6 @@ const config = {
6
6
  json: 'json',
7
7
  xml: 'xml',
8
8
  },
9
- method: {
10
- auth: 'auth.getToken',
11
- user: {
12
- getInfo: 'user.getInfo',
13
- loved_tracks: 'user.getLovedTracks',
14
- recent_tracks: 'user.getRecentTracks',
15
- top_albums: 'user.getTopAlbums',
16
- top_artists: 'user.getTopArtists',
17
- top_tracks: 'user.getTopTracks',
18
- weekly_album_chart: 'user.getWeeklyAlbumChart',
19
- weekly_artist_chart: 'user.getWeeklyArtistChart',
20
- weekly_chart_list: 'user.getWeeklyChartList',
21
- weekly_track_chart: 'user.getWeeklyTrackChart',
22
- },
23
- },
24
9
  share_secret: `${process.env.LASTFM_SHARED_SECRET}`,
25
10
  username: `${process.env.LASTFM_USER}`,
26
11
  };
27
-
28
- export default config;
package/src/index.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import config from './config';
2
+ import method from './method';
3
+ import request from './request';
1
4
  import {
2
5
  AuthResponse,
3
6
  LovedTracksResponse,
@@ -11,7 +14,6 @@ import {
11
14
  WeeklyChartListResponse,
12
15
  WeeklyTrackChartResponse,
13
16
  } from './types';
14
- import request from './request';
15
17
 
16
18
  const LastFmApi = function LastFmApi() {
17
19
  /**
@@ -185,6 +187,7 @@ const LastFmApi = function LastFmApi() {
185
187
 
186
188
  return {
187
189
  auth,
190
+ config,
188
191
  getInfo,
189
192
  getLovedTracks,
190
193
  getRecentTracks,
@@ -195,6 +198,7 @@ const LastFmApi = function LastFmApi() {
195
198
  getWeeklyArtistChart,
196
199
  getWeeklyChartList,
197
200
  getWeeklyTrackChart,
201
+ method,
198
202
  };
199
203
  };
200
204
 
package/src/method.ts ADDED
@@ -0,0 +1,15 @@
1
+ export default {
2
+ auth: 'auth.getToken',
3
+ user: {
4
+ getInfo: 'user.getInfo',
5
+ loved_tracks: 'user.getLovedTracks',
6
+ recent_tracks: 'user.getRecentTracks',
7
+ top_albums: 'user.getTopAlbums',
8
+ top_artists: 'user.getTopArtists',
9
+ top_tracks: 'user.getTopTracks',
10
+ weekly_album_chart: 'user.getWeeklyAlbumChart',
11
+ weekly_artist_chart: 'user.getWeeklyArtistChart',
12
+ weekly_chart_list: 'user.getWeeklyChartList',
13
+ weekly_track_chart: 'user.getWeeklyTrackChart',
14
+ },
15
+ };
package/tsconfig.json CHANGED
@@ -44,7 +44,7 @@
44
44
  // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
45
 
46
46
  /* Emit */
47
- // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
47
+ "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
48
48
  // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
49
  // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
50
  // "sourceMap": true, /* Create source map files for emitted JavaScript files. */