lastfm-nodejs-client 1.3.0 → 1.4.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/.env.example +6 -5
- package/@types/index.d.ts +3 -3
- package/CHANGELOG.md +10 -0
- package/package.json +11 -12
- package/src/config.ts +10 -2
- package/src/index.ts +19 -19
- package/src/method.ts +19 -19
- package/src/request.ts +6 -2
- package/tsconfig.json +15 -15
- package/bun.lockb +0 -0
- package/dist/auth.d.ts +0 -12
- package/dist/auth.js +0 -23
- package/dist/config.d.ts +0 -12
- package/dist/config.js +0 -39
- package/dist/createOptions.d.ts +0 -6
- package/dist/createOptions.js +0 -12
- package/dist/getInfo.d.ts +0 -8
- package/dist/getInfo.js +0 -19
- package/dist/getLovedTracks.d.ts +0 -8
- package/dist/getLovedTracks.js +0 -19
- package/dist/getRecentTracks.d.ts +0 -8
- package/dist/getRecentTracks.js +0 -19
- package/dist/getTopAlbums.d.ts +0 -8
- package/dist/getTopAlbums.js +0 -19
- package/dist/getTopArtists.d.ts +0 -8
- package/dist/getTopArtists.js +0 -19
- package/dist/getTopTracks.d.ts +0 -8
- package/dist/getTopTracks.js +0 -19
- package/dist/getWeeklyAlbumChart.d.ts +0 -8
- package/dist/getWeeklyAlbumChart.js +0 -19
- package/dist/getWeeklyArtistChart.d.ts +0 -8
- package/dist/getWeeklyArtistChart.js +0 -19
- package/dist/getWeeklyChartList.d.ts +0 -8
- package/dist/getWeeklyChartList.js +0 -19
- package/dist/getWeeklyTrackChart.d.ts +0 -8
- package/dist/getWeeklyTrackChart.js +0 -19
- package/dist/index.d.ts +0 -50
- package/dist/index.js +0 -36
- package/dist/method.d.ts +0 -32
- package/dist/method.js +0 -19
- package/dist/request.d.ts +0 -8
- package/dist/request.js +0 -129
package/.env.example
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
LASTFM_API_BASE_URL=
|
|
2
|
-
LASTFM_API_KEY=
|
|
3
|
-
LASTFM_APPNAME=
|
|
4
|
-
LASTFM_SHARED_SECRET=
|
|
5
|
-
LASTFM_USER=
|
|
1
|
+
LASTFM_API_BASE_URL=https://ws.audioscrobbler.com/2.0/
|
|
2
|
+
LASTFM_API_KEY=f7177932c78b9723d54e617d0d5695ee
|
|
3
|
+
LASTFM_APPNAME=music-wall
|
|
4
|
+
LASTFM_SHARED_SECRET=bcffbbc0ba4af16fc00415c94b138c74
|
|
5
|
+
LASTFM_USER=mannuelf
|
|
6
|
+
LASTFM_REGISTERTO=mannuelf
|
package/@types/index.d.ts
CHANGED
|
@@ -108,7 +108,7 @@ export type Artist = {
|
|
|
108
108
|
rank: number;
|
|
109
109
|
};
|
|
110
110
|
cover: ArtistImage;
|
|
111
|
-
image?:
|
|
111
|
+
image?: Image[];
|
|
112
112
|
mbid: string;
|
|
113
113
|
name: string;
|
|
114
114
|
playcount: number;
|
|
@@ -278,7 +278,7 @@ export interface WeeklyTrackChartAttr2 {
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
export const LastFmApi: () => {
|
|
281
|
-
auth: (method: string, user: string
|
|
281
|
+
auth: (method: string, user: string) => Promise<AuthResponse>;
|
|
282
282
|
config: {
|
|
283
283
|
api_key: string;
|
|
284
284
|
app_name: string;
|
|
@@ -290,7 +290,7 @@ export const LastFmApi: () => {
|
|
|
290
290
|
share_secret: string;
|
|
291
291
|
username: string;
|
|
292
292
|
};
|
|
293
|
-
getInfo: (method: string, user: string
|
|
293
|
+
getInfo: (method: string, user: string) => Promise<UserResponse>;
|
|
294
294
|
getLovedTracks: (
|
|
295
295
|
method: string,
|
|
296
296
|
user: string,
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.4.1
|
|
4
|
+
|
|
5
|
+
- export esm modules modern js only.
|
|
6
|
+
- add all dts and dts map files to dist
|
|
7
|
+
- adds lastfm types to dist
|
|
8
|
+
|
|
9
|
+
## 1.4.0
|
|
10
|
+
|
|
11
|
+
- update all api functions from snake case to camel case.
|
|
12
|
+
|
|
3
13
|
## 1.3.0
|
|
4
14
|
|
|
5
15
|
- Updates npm dependencies.
|
package/package.json
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lastfm-nodejs-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "A NodeJS wrapper client for LastFm API. Fetching public data by username using the LastFm public API",
|
|
5
5
|
"main": "./dist",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "rimraf dist && tsc",
|
|
8
|
-
"clean": "rimraf dist",
|
|
9
|
-
"dev": "npm run clean && tsc --watch --project tsconfig.dev.json",
|
|
10
|
-
"test": "npx playwright test --reporter=list"
|
|
11
|
-
},
|
|
12
6
|
"keywords": [
|
|
13
7
|
"client",
|
|
14
8
|
"lastFm",
|
|
@@ -27,10 +21,9 @@
|
|
|
27
21
|
"rimraf": "^5.0.1"
|
|
28
22
|
},
|
|
29
23
|
"devDependencies": {
|
|
30
|
-
"@playwright/test": "^1.
|
|
31
|
-
"@types/node": "^20.6.
|
|
32
|
-
"typescript": "^5.2.2"
|
|
33
|
-
"bun-types": "latest"
|
|
24
|
+
"@playwright/test": "^1.38.0",
|
|
25
|
+
"@types/node": "^20.6.2",
|
|
26
|
+
"typescript": "^5.2.2"
|
|
34
27
|
},
|
|
35
28
|
"repository": {
|
|
36
29
|
"type": "git",
|
|
@@ -39,5 +32,11 @@
|
|
|
39
32
|
"bugs": {
|
|
40
33
|
"url": "https://github.com/mannuelf/lastfm-nodejs-client/issues"
|
|
41
34
|
},
|
|
42
|
-
"homepage": "https://github.com/mannuelf/lastfm-nodejs-client#readme"
|
|
35
|
+
"homepage": "https://github.com/mannuelf/lastfm-nodejs-client#readme",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "rimraf dist && tsc && cp -r @types/ dist/@types/",
|
|
38
|
+
"clean": "rimraf dist",
|
|
39
|
+
"dev": "npm run clean && tsc --watch --project tsconfig.dev.json",
|
|
40
|
+
"test": "npx playwright test --reporter=list"
|
|
41
|
+
}
|
|
43
42
|
}
|
package/src/config.ts
CHANGED
|
@@ -12,8 +12,16 @@ interface Config {
|
|
|
12
12
|
share_secret: string;
|
|
13
13
|
username: string;
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @description Stores the Last.fm API key, app name, base url, format, shared secret, and username.
|
|
17
|
+
* Simply add a .env file to the root of the project and add the following:
|
|
18
|
+
* LASTFM_API_KEY=your_api_key
|
|
19
|
+
* LASTFM_APPNAME=your_app_name
|
|
20
|
+
* LASTFM_API_BASE_URL=your_base_url
|
|
21
|
+
* LASTFM_SHARED_SECRET=your_shared_secret
|
|
22
|
+
* LASTFM_USER=your_username
|
|
23
|
+
*/
|
|
24
|
+
export const config = {
|
|
17
25
|
api_key: `${process.env.LASTFM_API_KEY}`,
|
|
18
26
|
app_name: `${process.env.LASTFM_APPNAME}`,
|
|
19
27
|
base_url: `${process.env.LASTFM_API_BASE_URL}`,
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { auth } from './auth';
|
|
2
|
-
import config from './config';
|
|
2
|
+
import { config } from './config';
|
|
3
3
|
import { getInfo } from './getInfo';
|
|
4
4
|
import { getLovedTracks } from './getLovedTracks';
|
|
5
5
|
import { getRecentTracks } from './getRecentTracks';
|
|
@@ -10,22 +10,22 @@ import { getWeeklyAlbumChart } from './getWeeklyAlbumChart';
|
|
|
10
10
|
import { getWeeklyArtistChart } from './getWeeklyArtistChart';
|
|
11
11
|
import { getWeeklyChartList } from './getWeeklyChartList';
|
|
12
12
|
import { getWeeklyTrackChart } from './getWeeklyTrackChart';
|
|
13
|
-
import method from './method';
|
|
13
|
+
import { method } from './method';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
const LastFmApi = () => ({
|
|
16
|
+
auth,
|
|
17
|
+
config,
|
|
18
|
+
getInfo,
|
|
19
|
+
getLovedTracks,
|
|
20
|
+
getRecentTracks,
|
|
21
|
+
getTopAlbums,
|
|
22
|
+
getTopArtists,
|
|
23
|
+
getTopTracks,
|
|
24
|
+
getWeeklyAlbumChart,
|
|
25
|
+
getWeeklyArtistChart,
|
|
26
|
+
getWeeklyChartList,
|
|
27
|
+
getWeeklyTrackChart,
|
|
28
|
+
method,
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
export default LastFmApi;
|
package/src/method.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
interface UserMethod {
|
|
2
2
|
getInfo: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
getLovedTracks: string;
|
|
4
|
+
getRecentTracks: string;
|
|
5
|
+
getTopAlbums: string;
|
|
6
|
+
getTopArtists: string;
|
|
7
|
+
getTopTracks: string;
|
|
8
|
+
getWeeklyAlbumChart: string;
|
|
9
|
+
getWeeklyArtistChart: string;
|
|
10
|
+
getWeeklyChartList: string;
|
|
11
|
+
getWeeklyTrackChart: string;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export interface Method {
|
|
@@ -16,18 +16,18 @@ export interface Method {
|
|
|
16
16
|
user: UserMethod;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export
|
|
19
|
+
export const method = {
|
|
20
20
|
auth: 'auth.getToken',
|
|
21
21
|
user: {
|
|
22
22
|
getInfo: 'user.getInfo',
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
getLovedTracks: 'user.getLovedTracks',
|
|
24
|
+
getRecentTracks: 'user.getRecentTracks',
|
|
25
|
+
getTopAlbums: 'user.getTopAlbums',
|
|
26
|
+
getTopArtists: 'user.getTopArtists',
|
|
27
|
+
getTopTracks: 'user.getTopTracks',
|
|
28
|
+
getWeeklyAlbumChart: 'user.getWeeklyAlbumChart',
|
|
29
|
+
getWeeklyArtistChart: 'user.getWeeklyArtistChart',
|
|
30
|
+
getWeeklyChartList: 'user.getWeeklyChartList',
|
|
31
|
+
getWeeklyTrackChart: 'user.getWeeklyTrackChart',
|
|
32
32
|
},
|
|
33
33
|
} satisfies Method;
|
package/src/request.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fetch from 'cross-fetch';
|
|
2
|
-
import config from './config';
|
|
2
|
+
import { config } from './config';
|
|
3
3
|
|
|
4
4
|
interface RequestOptions {
|
|
5
5
|
method: string;
|
|
@@ -49,6 +49,10 @@ const request = async <Response>(options: RequestOptions): Promise<Response> =>
|
|
|
49
49
|
},
|
|
50
50
|
})
|
|
51
51
|
.then((res) => {
|
|
52
|
+
if(!res.ok) {
|
|
53
|
+
throw new Error(res.statusText);
|
|
54
|
+
}
|
|
55
|
+
|
|
52
56
|
switch (res.status) {
|
|
53
57
|
case 200: {
|
|
54
58
|
return res.json();
|
|
@@ -122,7 +126,7 @@ const request = async <Response>(options: RequestOptions): Promise<Response> =>
|
|
|
122
126
|
})
|
|
123
127
|
.then((json) => json)
|
|
124
128
|
.catch((error) => {
|
|
125
|
-
console.log(error);
|
|
129
|
+
console.log('🚨 error:', error);
|
|
126
130
|
})) as Response;
|
|
127
131
|
};
|
|
128
132
|
|
package/tsconfig.json
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
13
13
|
|
|
14
14
|
/* Language and Environment */
|
|
15
|
-
"target": "
|
|
16
|
-
|
|
15
|
+
"target": "ES6" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
16
|
+
"lib": ["DOM", "ESNext"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
17
17
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
18
18
|
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
19
19
|
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
@@ -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. */
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
46
46
|
|
|
47
47
|
/* Emit */
|
|
48
|
-
"declaration": true
|
|
49
|
-
|
|
48
|
+
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
|
49
|
+
"declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
50
50
|
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
51
51
|
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
52
52
|
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
53
|
-
"outDir": "./dist"
|
|
54
|
-
"removeComments": false,
|
|
53
|
+
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
|
54
|
+
"removeComments": false, /* Disable emitting comments. */
|
|
55
55
|
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
56
56
|
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
57
57
|
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
58
|
-
|
|
58
|
+
"downlevelIteration": false, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
59
59
|
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
60
60
|
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
61
61
|
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
71
71
|
|
|
72
72
|
/* Interop Constraints */
|
|
73
|
-
"isolatedModules": true
|
|
74
|
-
|
|
75
|
-
"esModuleInterop": true
|
|
73
|
+
"isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
|
|
74
|
+
"allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
75
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
76
76
|
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
77
|
-
"forceConsistentCasingInFileNames": true
|
|
77
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
78
78
|
|
|
79
79
|
/* Type Checking */
|
|
80
80
|
"strict": true /* Enable all strict type-checking options. */,
|
|
@@ -101,4 +101,4 @@
|
|
|
101
101
|
"skipDefaultLibCheck": true /* Skip type checking .d.ts files that are included with TypeScript. */,
|
|
102
102
|
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
103
103
|
}
|
|
104
|
-
}
|
|
104
|
+
}
|
package/bun.lockb
DELETED
|
Binary file
|
package/dist/auth.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AuthResponse } from '../@types';
|
|
2
|
-
/**
|
|
3
|
-
* POST: Auth - LastFM
|
|
4
|
-
*
|
|
5
|
-
* https://www.last.fm/api/show/auth.getToken
|
|
6
|
-
*
|
|
7
|
-
* Authentication tokens are API account specific.
|
|
8
|
-
* They are valid for 60 minutes from the moment they are granted.
|
|
9
|
-
* Can only used once (they are consumed when a session is created).
|
|
10
|
-
* @returns Auth token
|
|
11
|
-
*/
|
|
12
|
-
export declare function auth(method: string, user: string, period: string, limit: string): Promise<AuthResponse>;
|
package/dist/auth.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.auth = void 0;
|
|
7
|
-
const createOptions_1 = require("./createOptions");
|
|
8
|
-
const request_1 = __importDefault(require("./request"));
|
|
9
|
-
/**
|
|
10
|
-
* POST: Auth - LastFM
|
|
11
|
-
*
|
|
12
|
-
* https://www.last.fm/api/show/auth.getToken
|
|
13
|
-
*
|
|
14
|
-
* Authentication tokens are API account specific.
|
|
15
|
-
* They are valid for 60 minutes from the moment they are granted.
|
|
16
|
-
* Can only used once (they are consumed when a session is created).
|
|
17
|
-
* @returns Auth token
|
|
18
|
-
*/
|
|
19
|
-
function auth(method, user, period, limit) {
|
|
20
|
-
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
21
|
-
return (0, request_1.default)(options);
|
|
22
|
-
}
|
|
23
|
-
exports.auth = auth;
|
package/dist/config.d.ts
DELETED
package/dist/config.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const dotenv = __importStar(require("dotenv"));
|
|
27
|
-
dotenv.config();
|
|
28
|
-
;
|
|
29
|
-
exports.default = {
|
|
30
|
-
api_key: `${process.env.LASTFM_API_KEY}`,
|
|
31
|
-
app_name: `${process.env.LASTFM_APPNAME}`,
|
|
32
|
-
base_url: `${process.env.LASTFM_API_BASE_URL}`,
|
|
33
|
-
format: {
|
|
34
|
-
json: 'json',
|
|
35
|
-
xml: 'xml',
|
|
36
|
-
},
|
|
37
|
-
share_secret: `${process.env.LASTFM_SHARED_SECRET}`,
|
|
38
|
-
username: `${process.env.LASTFM_USER}`,
|
|
39
|
-
};
|
package/dist/createOptions.d.ts
DELETED
package/dist/createOptions.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createOptions = void 0;
|
|
4
|
-
function createOptions(method, user, period, limit) {
|
|
5
|
-
return {
|
|
6
|
-
method,
|
|
7
|
-
user,
|
|
8
|
-
period,
|
|
9
|
-
limit,
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
exports.createOptions = createOptions;
|
package/dist/getInfo.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { UserResponse } from '../@types';
|
|
2
|
-
/**
|
|
3
|
-
* GET: User profile information - LastFM
|
|
4
|
-
*
|
|
5
|
-
* https://www.last.fm/api/show/user.getInfo
|
|
6
|
-
* @returns User profile information
|
|
7
|
-
*/
|
|
8
|
-
export declare function getInfo(method: string, user: string): Promise<UserResponse>;
|
package/dist/getInfo.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getInfo = void 0;
|
|
7
|
-
const createOptions_1 = require("./createOptions");
|
|
8
|
-
const request_1 = __importDefault(require("./request"));
|
|
9
|
-
/**
|
|
10
|
-
* GET: User profile information - LastFM
|
|
11
|
-
*
|
|
12
|
-
* https://www.last.fm/api/show/user.getInfo
|
|
13
|
-
* @returns User profile information
|
|
14
|
-
*/
|
|
15
|
-
function getInfo(method, user) {
|
|
16
|
-
const options = (0, createOptions_1.createOptions)(method, user);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
18
|
-
}
|
|
19
|
-
exports.getInfo = getInfo;
|
package/dist/getLovedTracks.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { LovedTracksResponse } from '../@types';
|
|
2
|
-
/**
|
|
3
|
-
* GET: Love Tracks - LastFM
|
|
4
|
-
*
|
|
5
|
-
* https://www.last.fm/api/show/user.getLovedTracks
|
|
6
|
-
* @returns Loved Tracks;
|
|
7
|
-
*/
|
|
8
|
-
export declare function getLovedTracks(method: string, user: string, period: string, limit: string): Promise<LovedTracksResponse>;
|
package/dist/getLovedTracks.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getLovedTracks = void 0;
|
|
7
|
-
const createOptions_1 = require("./createOptions");
|
|
8
|
-
const request_1 = __importDefault(require("./request"));
|
|
9
|
-
/**
|
|
10
|
-
* GET: Love Tracks - LastFM
|
|
11
|
-
*
|
|
12
|
-
* https://www.last.fm/api/show/user.getLovedTracks
|
|
13
|
-
* @returns Loved Tracks;
|
|
14
|
-
*/
|
|
15
|
-
function getLovedTracks(method, user, period, limit) {
|
|
16
|
-
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
18
|
-
}
|
|
19
|
-
exports.getLovedTracks = getLovedTracks;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RecentTracksResponse } from '../@types';
|
|
2
|
-
/**
|
|
3
|
-
* GET: Recent Tracks - LastFM
|
|
4
|
-
*
|
|
5
|
-
* https://www.last.fm/api/show/user.getRecentTracks
|
|
6
|
-
* @returns Recent Tracks
|
|
7
|
-
*/
|
|
8
|
-
export declare function getRecentTracks(method: string, user: string, period: string, limit: string): Promise<RecentTracksResponse>;
|
package/dist/getRecentTracks.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getRecentTracks = void 0;
|
|
7
|
-
const createOptions_1 = require("./createOptions");
|
|
8
|
-
const request_1 = __importDefault(require("./request"));
|
|
9
|
-
/**
|
|
10
|
-
* GET: Recent Tracks - LastFM
|
|
11
|
-
*
|
|
12
|
-
* https://www.last.fm/api/show/user.getRecentTracks
|
|
13
|
-
* @returns Recent Tracks
|
|
14
|
-
*/
|
|
15
|
-
function getRecentTracks(method, user, period, limit) {
|
|
16
|
-
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
18
|
-
}
|
|
19
|
-
exports.getRecentTracks = getRecentTracks;
|
package/dist/getTopAlbums.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TopAlbumsResponse } from '../@types';
|
|
2
|
-
/**
|
|
3
|
-
* GET: Top Albums - LastFM
|
|
4
|
-
*
|
|
5
|
-
* https://www.last.fm/api/show/user.getTopAlbums
|
|
6
|
-
* @returns Top Albums
|
|
7
|
-
*/
|
|
8
|
-
export declare function getTopAlbums(method: string, user: string, period: string, limit: string): Promise<TopAlbumsResponse>;
|
package/dist/getTopAlbums.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getTopAlbums = void 0;
|
|
7
|
-
const createOptions_1 = require("./createOptions");
|
|
8
|
-
const request_1 = __importDefault(require("./request"));
|
|
9
|
-
/**
|
|
10
|
-
* GET: Top Albums - LastFM
|
|
11
|
-
*
|
|
12
|
-
* https://www.last.fm/api/show/user.getTopAlbums
|
|
13
|
-
* @returns Top Albums
|
|
14
|
-
*/
|
|
15
|
-
function getTopAlbums(method, user, period, limit) {
|
|
16
|
-
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
18
|
-
}
|
|
19
|
-
exports.getTopAlbums = getTopAlbums;
|
package/dist/getTopArtists.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TopArtistsResponse } from '../@types';
|
|
2
|
-
/**
|
|
3
|
-
* GET: Top Artist - LastFM
|
|
4
|
-
*
|
|
5
|
-
* https://www.last.fm/api/show/user.getTopArtists
|
|
6
|
-
* @returns Top Artists
|
|
7
|
-
*/
|
|
8
|
-
export declare function getTopArtists(method: string, user: string, period: string, limit: string): Promise<TopArtistsResponse>;
|
package/dist/getTopArtists.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getTopArtists = void 0;
|
|
7
|
-
const createOptions_1 = require("./createOptions");
|
|
8
|
-
const request_1 = __importDefault(require("./request"));
|
|
9
|
-
/**
|
|
10
|
-
* GET: Top Artist - LastFM
|
|
11
|
-
*
|
|
12
|
-
* https://www.last.fm/api/show/user.getTopArtists
|
|
13
|
-
* @returns Top Artists
|
|
14
|
-
*/
|
|
15
|
-
function getTopArtists(method, user, period, limit) {
|
|
16
|
-
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
18
|
-
}
|
|
19
|
-
exports.getTopArtists = getTopArtists;
|
package/dist/getTopTracks.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TopTrackResponse } from '../@types';
|
|
2
|
-
/**
|
|
3
|
-
* GET: Top Tracks - LastFM
|
|
4
|
-
*
|
|
5
|
-
* https://www.last.fm/api/show/user.getTopTracks
|
|
6
|
-
* @returns Top Tracks
|
|
7
|
-
*/
|
|
8
|
-
export declare function getTopTracks(method: string, user: string, period: string, limit: string): Promise<TopTrackResponse>;
|
package/dist/getTopTracks.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getTopTracks = void 0;
|
|
7
|
-
const createOptions_1 = require("./createOptions");
|
|
8
|
-
const request_1 = __importDefault(require("./request"));
|
|
9
|
-
/**
|
|
10
|
-
* GET: Top Tracks - LastFM
|
|
11
|
-
*
|
|
12
|
-
* https://www.last.fm/api/show/user.getTopTracks
|
|
13
|
-
* @returns Top Tracks
|
|
14
|
-
*/
|
|
15
|
-
function getTopTracks(method, user, period, limit) {
|
|
16
|
-
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
18
|
-
}
|
|
19
|
-
exports.getTopTracks = getTopTracks;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { WeeklyAlbumChartResponse } from '../@types';
|
|
2
|
-
/**
|
|
3
|
-
* GET: Weekly album chart - LastFM
|
|
4
|
-
*
|
|
5
|
-
* https://www.last.fm/api/show/user.getWeeklyAlbumChart
|
|
6
|
-
* @returns Weekly album chart
|
|
7
|
-
*/
|
|
8
|
-
export declare function getWeeklyAlbumChart(method: string, user: string, period: string, limit: string): Promise<WeeklyAlbumChartResponse>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getWeeklyAlbumChart = void 0;
|
|
7
|
-
const createOptions_1 = require("./createOptions");
|
|
8
|
-
const request_1 = __importDefault(require("./request"));
|
|
9
|
-
/**
|
|
10
|
-
* GET: Weekly album chart - LastFM
|
|
11
|
-
*
|
|
12
|
-
* https://www.last.fm/api/show/user.getWeeklyAlbumChart
|
|
13
|
-
* @returns Weekly album chart
|
|
14
|
-
*/
|
|
15
|
-
function getWeeklyAlbumChart(method, user, period, limit) {
|
|
16
|
-
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
18
|
-
}
|
|
19
|
-
exports.getWeeklyAlbumChart = getWeeklyAlbumChart;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { WeeklyArtistChartResponse } from '../@types';
|
|
2
|
-
/**
|
|
3
|
-
* GET: Weekly artist chart - LastFM
|
|
4
|
-
*
|
|
5
|
-
* https://www.last.fm/api/show/user.getWeeklyArtistChart
|
|
6
|
-
* @returns Weekly artist chart
|
|
7
|
-
*/
|
|
8
|
-
export declare function getWeeklyArtistChart(method: string, user: string, period: string, limit: string): Promise<WeeklyArtistChartResponse>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getWeeklyArtistChart = void 0;
|
|
7
|
-
const createOptions_1 = require("./createOptions");
|
|
8
|
-
const request_1 = __importDefault(require("./request"));
|
|
9
|
-
/**
|
|
10
|
-
* GET: Weekly artist chart - LastFM
|
|
11
|
-
*
|
|
12
|
-
* https://www.last.fm/api/show/user.getWeeklyArtistChart
|
|
13
|
-
* @returns Weekly artist chart
|
|
14
|
-
*/
|
|
15
|
-
function getWeeklyArtistChart(method, user, period, limit) {
|
|
16
|
-
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
18
|
-
}
|
|
19
|
-
exports.getWeeklyArtistChart = getWeeklyArtistChart;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { WeeklyChartListResponse } from '../@types';
|
|
2
|
-
/**
|
|
3
|
-
* GET: Weekly chart list - LastFM
|
|
4
|
-
*
|
|
5
|
-
* https://www.last.fm/api/show/user.getWeeklyChartList
|
|
6
|
-
* @returns Weekly chart list
|
|
7
|
-
*/
|
|
8
|
-
export declare function getWeeklyChartList(method: string, user: string, period: string, limit: string): Promise<WeeklyChartListResponse>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getWeeklyChartList = void 0;
|
|
7
|
-
const createOptions_1 = require("./createOptions");
|
|
8
|
-
const request_1 = __importDefault(require("./request"));
|
|
9
|
-
/**
|
|
10
|
-
* GET: Weekly chart list - LastFM
|
|
11
|
-
*
|
|
12
|
-
* https://www.last.fm/api/show/user.getWeeklyChartList
|
|
13
|
-
* @returns Weekly chart list
|
|
14
|
-
*/
|
|
15
|
-
function getWeeklyChartList(method, user, period, limit) {
|
|
16
|
-
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
18
|
-
}
|
|
19
|
-
exports.getWeeklyChartList = getWeeklyChartList;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { WeeklyTrackChartResponse } from '../@types';
|
|
2
|
-
/**
|
|
3
|
-
* GET: Weekly track chart - LastFM
|
|
4
|
-
*
|
|
5
|
-
* https://www.last.fm/api/show/user.getWeeklyTrackChart
|
|
6
|
-
* @returns Weekly track chart
|
|
7
|
-
*/
|
|
8
|
-
export declare function getWeeklyTrackChart(method: string, user: string, period: string, limit: string): Promise<WeeklyTrackChartResponse>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getWeeklyTrackChart = void 0;
|
|
7
|
-
const createOptions_1 = require("./createOptions");
|
|
8
|
-
const request_1 = __importDefault(require("./request"));
|
|
9
|
-
/**
|
|
10
|
-
* GET: Weekly track chart - LastFM
|
|
11
|
-
*
|
|
12
|
-
* https://www.last.fm/api/show/user.getWeeklyTrackChart
|
|
13
|
-
* @returns Weekly track chart
|
|
14
|
-
*/
|
|
15
|
-
function getWeeklyTrackChart(method, user, period, limit) {
|
|
16
|
-
const options = (0, createOptions_1.createOptions)(method, user, period, limit);
|
|
17
|
-
return (0, request_1.default)(options);
|
|
18
|
-
}
|
|
19
|
-
exports.getWeeklyTrackChart = getWeeklyTrackChart;
|
package/dist/index.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { auth } from './auth';
|
|
2
|
-
import { getInfo } from './getInfo';
|
|
3
|
-
import { getLovedTracks } from './getLovedTracks';
|
|
4
|
-
import { getRecentTracks } from './getRecentTracks';
|
|
5
|
-
import { getTopAlbums } from './getTopAlbums';
|
|
6
|
-
import { getTopArtists } from './getTopArtists';
|
|
7
|
-
import { getTopTracks } from './getTopTracks';
|
|
8
|
-
import { getWeeklyAlbumChart } from './getWeeklyAlbumChart';
|
|
9
|
-
import { getWeeklyArtistChart } from './getWeeklyArtistChart';
|
|
10
|
-
import { getWeeklyChartList } from './getWeeklyChartList';
|
|
11
|
-
import { getWeeklyTrackChart } from './getWeeklyTrackChart';
|
|
12
|
-
export default function LastFmApi(): {
|
|
13
|
-
auth: typeof auth;
|
|
14
|
-
config: {
|
|
15
|
-
api_key: string;
|
|
16
|
-
app_name: string;
|
|
17
|
-
base_url: string;
|
|
18
|
-
format: {
|
|
19
|
-
json: string;
|
|
20
|
-
xml: string;
|
|
21
|
-
};
|
|
22
|
-
share_secret: string;
|
|
23
|
-
username: string;
|
|
24
|
-
};
|
|
25
|
-
getInfo: typeof getInfo;
|
|
26
|
-
getLovedTracks: typeof getLovedTracks;
|
|
27
|
-
getRecentTracks: typeof getRecentTracks;
|
|
28
|
-
getTopAlbums: typeof getTopAlbums;
|
|
29
|
-
getTopArtists: typeof getTopArtists;
|
|
30
|
-
getTopTracks: typeof getTopTracks;
|
|
31
|
-
getWeeklyAlbumChart: typeof getWeeklyAlbumChart;
|
|
32
|
-
getWeeklyArtistChart: typeof getWeeklyArtistChart;
|
|
33
|
-
getWeeklyChartList: typeof getWeeklyChartList;
|
|
34
|
-
getWeeklyTrackChart: typeof getWeeklyTrackChart;
|
|
35
|
-
method: {
|
|
36
|
-
auth: string;
|
|
37
|
-
user: {
|
|
38
|
-
getInfo: string;
|
|
39
|
-
loved_tracks: string;
|
|
40
|
-
recent_tracks: string;
|
|
41
|
-
top_albums: string;
|
|
42
|
-
top_artists: string;
|
|
43
|
-
top_tracks: string;
|
|
44
|
-
weekly_album_chart: string;
|
|
45
|
-
weekly_artist_chart: string;
|
|
46
|
-
weekly_chart_list: string;
|
|
47
|
-
weekly_track_chart: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
};
|
package/dist/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const auth_1 = require("./auth");
|
|
7
|
-
const config_1 = __importDefault(require("./config"));
|
|
8
|
-
const getInfo_1 = require("./getInfo");
|
|
9
|
-
const getLovedTracks_1 = require("./getLovedTracks");
|
|
10
|
-
const getRecentTracks_1 = require("./getRecentTracks");
|
|
11
|
-
const getTopAlbums_1 = require("./getTopAlbums");
|
|
12
|
-
const getTopArtists_1 = require("./getTopArtists");
|
|
13
|
-
const getTopTracks_1 = require("./getTopTracks");
|
|
14
|
-
const getWeeklyAlbumChart_1 = require("./getWeeklyAlbumChart");
|
|
15
|
-
const getWeeklyArtistChart_1 = require("./getWeeklyArtistChart");
|
|
16
|
-
const getWeeklyChartList_1 = require("./getWeeklyChartList");
|
|
17
|
-
const getWeeklyTrackChart_1 = require("./getWeeklyTrackChart");
|
|
18
|
-
const method_1 = __importDefault(require("./method"));
|
|
19
|
-
function LastFmApi() {
|
|
20
|
-
return {
|
|
21
|
-
auth: auth_1.auth,
|
|
22
|
-
config: config_1.default,
|
|
23
|
-
getInfo: getInfo_1.getInfo,
|
|
24
|
-
getLovedTracks: getLovedTracks_1.getLovedTracks,
|
|
25
|
-
getRecentTracks: getRecentTracks_1.getRecentTracks,
|
|
26
|
-
getTopAlbums: getTopAlbums_1.getTopAlbums,
|
|
27
|
-
getTopArtists: getTopArtists_1.getTopArtists,
|
|
28
|
-
getTopTracks: getTopTracks_1.getTopTracks,
|
|
29
|
-
getWeeklyAlbumChart: getWeeklyAlbumChart_1.getWeeklyAlbumChart,
|
|
30
|
-
getWeeklyArtistChart: getWeeklyArtistChart_1.getWeeklyArtistChart,
|
|
31
|
-
getWeeklyChartList: getWeeklyChartList_1.getWeeklyChartList,
|
|
32
|
-
getWeeklyTrackChart: getWeeklyTrackChart_1.getWeeklyTrackChart,
|
|
33
|
-
method: method_1.default,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
exports.default = LastFmApi;
|
package/dist/method.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
interface UserMethod {
|
|
2
|
-
getInfo: string;
|
|
3
|
-
loved_tracks: string;
|
|
4
|
-
recent_tracks: string;
|
|
5
|
-
top_albums: string;
|
|
6
|
-
top_artists: string;
|
|
7
|
-
top_tracks: string;
|
|
8
|
-
weekly_album_chart: string;
|
|
9
|
-
weekly_artist_chart: string;
|
|
10
|
-
weekly_chart_list: string;
|
|
11
|
-
weekly_track_chart: string;
|
|
12
|
-
}
|
|
13
|
-
export interface Method {
|
|
14
|
-
auth: string;
|
|
15
|
-
user: UserMethod;
|
|
16
|
-
}
|
|
17
|
-
declare const _default: {
|
|
18
|
-
auth: string;
|
|
19
|
-
user: {
|
|
20
|
-
getInfo: string;
|
|
21
|
-
loved_tracks: string;
|
|
22
|
-
recent_tracks: string;
|
|
23
|
-
top_albums: string;
|
|
24
|
-
top_artists: string;
|
|
25
|
-
top_tracks: string;
|
|
26
|
-
weekly_album_chart: string;
|
|
27
|
-
weekly_artist_chart: string;
|
|
28
|
-
weekly_chart_list: string;
|
|
29
|
-
weekly_track_chart: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
export default _default;
|
package/dist/method.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
;
|
|
4
|
-
;
|
|
5
|
-
exports.default = {
|
|
6
|
-
auth: 'auth.getToken',
|
|
7
|
-
user: {
|
|
8
|
-
getInfo: 'user.getInfo',
|
|
9
|
-
loved_tracks: 'user.getLovedTracks',
|
|
10
|
-
recent_tracks: 'user.getRecentTracks',
|
|
11
|
-
top_albums: 'user.getTopAlbums',
|
|
12
|
-
top_artists: 'user.getTopArtists',
|
|
13
|
-
top_tracks: 'user.getTopTracks',
|
|
14
|
-
weekly_album_chart: 'user.getWeeklyAlbumChart',
|
|
15
|
-
weekly_artist_chart: 'user.getWeeklyArtistChart',
|
|
16
|
-
weekly_chart_list: 'user.getWeeklyChartList',
|
|
17
|
-
weekly_track_chart: 'user.getWeeklyTrackChart',
|
|
18
|
-
},
|
|
19
|
-
};
|
package/dist/request.d.ts
DELETED
package/dist/request.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
16
|
-
const config_1 = __importDefault(require("./config"));
|
|
17
|
-
var ErrorResponse;
|
|
18
|
-
(function (ErrorResponse) {
|
|
19
|
-
ErrorResponse[ErrorResponse["InvalidService"] = 2] = "InvalidService";
|
|
20
|
-
ErrorResponse[ErrorResponse["InvalidMethod"] = 3] = "InvalidMethod";
|
|
21
|
-
ErrorResponse[ErrorResponse["AuthenticationFailed"] = 4] = "AuthenticationFailed";
|
|
22
|
-
ErrorResponse[ErrorResponse["InvalidFormat"] = 5] = "InvalidFormat";
|
|
23
|
-
ErrorResponse[ErrorResponse["InvalidParameters"] = 6] = "InvalidParameters";
|
|
24
|
-
ErrorResponse[ErrorResponse["InvalidResource"] = 7] = "InvalidResource";
|
|
25
|
-
ErrorResponse[ErrorResponse["OperationFailed"] = 8] = "OperationFailed";
|
|
26
|
-
ErrorResponse[ErrorResponse["InvalidSessionKey"] = 9] = "InvalidSessionKey";
|
|
27
|
-
ErrorResponse[ErrorResponse["InvalidAPIKey"] = 10] = "InvalidAPIKey";
|
|
28
|
-
ErrorResponse[ErrorResponse["ServiceOffline"] = 11] = "ServiceOffline";
|
|
29
|
-
ErrorResponse[ErrorResponse["InvalidMethodSignature"] = 13] = "InvalidMethodSignature";
|
|
30
|
-
ErrorResponse[ErrorResponse["TemporaryError"] = 16] = "TemporaryError";
|
|
31
|
-
ErrorResponse[ErrorResponse["SuspendedAPIKey"] = 26] = "SuspendedAPIKey";
|
|
32
|
-
ErrorResponse[ErrorResponse["RateLimitExceeded"] = 29] = "RateLimitExceeded";
|
|
33
|
-
})(ErrorResponse || (ErrorResponse = {}));
|
|
34
|
-
const buildUrl = (options) => {
|
|
35
|
-
const params = new URLSearchParams();
|
|
36
|
-
params.append('method', options.method);
|
|
37
|
-
if (options.user)
|
|
38
|
-
params.append('user', options.user);
|
|
39
|
-
if (options.period)
|
|
40
|
-
params.append('period', options.period);
|
|
41
|
-
if (options.limit)
|
|
42
|
-
params.append('limit', options.limit);
|
|
43
|
-
params.append('api_key', config_1.default.api_key);
|
|
44
|
-
params.append('format', config_1.default.format.json);
|
|
45
|
-
return `${config_1.default.base_url}?${params.toString()}`;
|
|
46
|
-
};
|
|
47
|
-
const request = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
const url = buildUrl(options);
|
|
49
|
-
return (yield (0, cross_fetch_1.default)(url, {
|
|
50
|
-
headers: {
|
|
51
|
-
'Content-Type': 'application/json',
|
|
52
|
-
},
|
|
53
|
-
})
|
|
54
|
-
.then((res) => {
|
|
55
|
-
switch (res.status) {
|
|
56
|
-
case 200: {
|
|
57
|
-
return res.json();
|
|
58
|
-
}
|
|
59
|
-
case 400: {
|
|
60
|
-
throw new Error('Bad request');
|
|
61
|
-
}
|
|
62
|
-
case 401: {
|
|
63
|
-
throw new Error('Unauthorized');
|
|
64
|
-
}
|
|
65
|
-
case 403: {
|
|
66
|
-
throw new Error('Forbidden');
|
|
67
|
-
}
|
|
68
|
-
case 404: {
|
|
69
|
-
throw new Error('Not found');
|
|
70
|
-
}
|
|
71
|
-
case 500: {
|
|
72
|
-
throw new Error('Internal server error');
|
|
73
|
-
}
|
|
74
|
-
case 503: {
|
|
75
|
-
throw new Error('Service unavailable');
|
|
76
|
-
}
|
|
77
|
-
case ErrorResponse.InvalidAPIKey: {
|
|
78
|
-
throw new Error('Invalid API key');
|
|
79
|
-
}
|
|
80
|
-
case ErrorResponse.InvalidMethod: {
|
|
81
|
-
throw new Error('Invalid method');
|
|
82
|
-
}
|
|
83
|
-
case ErrorResponse.InvalidParameters: {
|
|
84
|
-
throw new Error('Invalid parameters');
|
|
85
|
-
}
|
|
86
|
-
case ErrorResponse.InvalidResource: {
|
|
87
|
-
throw new Error('Invalid resource');
|
|
88
|
-
}
|
|
89
|
-
case ErrorResponse.InvalidSessionKey: {
|
|
90
|
-
throw new Error('Invalid session key');
|
|
91
|
-
}
|
|
92
|
-
case ErrorResponse.InvalidService: {
|
|
93
|
-
throw new Error('Invalid service');
|
|
94
|
-
}
|
|
95
|
-
case ErrorResponse.OperationFailed: {
|
|
96
|
-
throw new Error('Operation failed');
|
|
97
|
-
}
|
|
98
|
-
case ErrorResponse.RateLimitExceeded: {
|
|
99
|
-
throw new Error('Rate limit exceeded');
|
|
100
|
-
}
|
|
101
|
-
case ErrorResponse.ServiceOffline: {
|
|
102
|
-
throw new Error('Service offline');
|
|
103
|
-
}
|
|
104
|
-
case ErrorResponse.SuspendedAPIKey: {
|
|
105
|
-
throw new Error('Suspended API key');
|
|
106
|
-
}
|
|
107
|
-
case ErrorResponse.TemporaryError: {
|
|
108
|
-
throw new Error('Temporary error');
|
|
109
|
-
}
|
|
110
|
-
case ErrorResponse.AuthenticationFailed: {
|
|
111
|
-
throw new Error('Authentication failed');
|
|
112
|
-
}
|
|
113
|
-
case ErrorResponse.InvalidFormat: {
|
|
114
|
-
throw new Error('Invalid format');
|
|
115
|
-
}
|
|
116
|
-
case ErrorResponse.InvalidMethodSignature: {
|
|
117
|
-
throw new Error('Invalid method signature');
|
|
118
|
-
}
|
|
119
|
-
default: {
|
|
120
|
-
throw new Error('Unknown error');
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
.then((json) => json)
|
|
125
|
-
.catch((error) => {
|
|
126
|
-
console.log(error);
|
|
127
|
-
}));
|
|
128
|
-
});
|
|
129
|
-
exports.default = request;
|