Skip to content

Commit b2cc951

Browse files
committed
breaking: update functions to camel case from snaek case.
1 parent 24bdd07 commit b2cc951

29 files changed

+91
-262
lines changed

.env.example

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
LASTFM_API_BASE_URL="https://ws.audioscrobbler.com/2.0/"
2-
LASTFM_API_KEY="abcdefghijkhlmnopqrstuvwxyz"
3-
LASTFM_APPNAME="your app name"
4-
LASTFM_SHARED_SECRET="xxxxxxxxxxxxxxxxxxxxx"
5-
LASTFM_USER="your username"
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

@types/index.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export type Artist = {
108108
rank: number;
109109
};
110110
cover: ArtistImage;
111-
image?: string;
111+
image?: Image[];
112112
mbid: string;
113113
name: string;
114114
playcount: number;
@@ -278,7 +278,7 @@ export interface WeeklyTrackChartAttr2 {
278278
}
279279

280280
export const LastFmApi: () => {
281-
auth: (method: string, user: string, period: string, limit: number) => Promise<AuthResponse>;
281+
auth: (method: string, user: string) => Promise<AuthResponse>;
282282
config: {
283283
api_key: string;
284284
app_name: string;
@@ -290,7 +290,7 @@ export const LastFmApi: () => {
290290
share_secret: string;
291291
username: string;
292292
};
293-
getInfo: (method: string, user: string, period: string, limit: number) => Promise<UserResponse>;
293+
getInfo: (method: string, user: string) => Promise<UserResponse>;
294294
getLovedTracks: (
295295
method: string,
296296
user: string,

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.4.0
4+
5+
- update all api functions from snake case to camel case.
6+
37
## 1.3.0
48

59
- Updates npm dependencies.

dist/auth.d.ts

-12
This file was deleted.

dist/config.d.ts

-12
This file was deleted.

dist/config.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
2323
return result;
2424
};
2525
Object.defineProperty(exports, "__esModule", { value: true });
26+
exports.config = void 0;
2627
const dotenv = __importStar(require("dotenv"));
2728
dotenv.config();
2829
;
29-
exports.default = {
30+
/**
31+
* @description Stores the Last.fm API key, app name, base url, format, shared secret, and username.
32+
* Simply add a .env file to the root of the project and add the following:
33+
* LASTFM_API_KEY=your_api_key
34+
* LASTFM_APPNAME=your_app_name
35+
* LASTFM_API_BASE_URL=your_base_url
36+
* LASTFM_SHARED_SECRET=your_shared_secret
37+
* LASTFM_USER=your_username
38+
*/
39+
exports.config = {
3040
api_key: `${process.env.LASTFM_API_KEY}`,
3141
app_name: `${process.env.LASTFM_APPNAME}`,
3242
base_url: `${process.env.LASTFM_API_BASE_URL}`,

dist/createOptions.d.ts

-6
This file was deleted.

dist/getInfo.d.ts

-8
This file was deleted.

dist/getLovedTracks.d.ts

-8
This file was deleted.

dist/getRecentTracks.d.ts

-8
This file was deleted.

dist/getTopAlbums.d.ts

-8
This file was deleted.

dist/getTopArtists.d.ts

-8
This file was deleted.

dist/getTopTracks.d.ts

-8
This file was deleted.

dist/getWeeklyAlbumChart.d.ts

-8
This file was deleted.

dist/getWeeklyArtistChart.d.ts

-8
This file was deleted.

dist/getWeeklyChartList.d.ts

-8
This file was deleted.

dist/getWeeklyTrackChart.d.ts

-8
This file was deleted.

dist/index.d.ts

-50
This file was deleted.

dist/index.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"use strict";
2-
var __importDefault = (this && this.__importDefault) || function (mod) {
3-
return (mod && mod.__esModule) ? mod : { "default": mod };
4-
};
52
Object.defineProperty(exports, "__esModule", { value: true });
63
const auth_1 = require("./auth");
7-
const config_1 = __importDefault(require("./config"));
4+
const config_1 = require("./config");
85
const getInfo_1 = require("./getInfo");
96
const getLovedTracks_1 = require("./getLovedTracks");
107
const getRecentTracks_1 = require("./getRecentTracks");
@@ -15,11 +12,11 @@ const getWeeklyAlbumChart_1 = require("./getWeeklyAlbumChart");
1512
const getWeeklyArtistChart_1 = require("./getWeeklyArtistChart");
1613
const getWeeklyChartList_1 = require("./getWeeklyChartList");
1714
const getWeeklyTrackChart_1 = require("./getWeeklyTrackChart");
18-
const method_1 = __importDefault(require("./method"));
15+
const method_1 = require("./method");
1916
function LastFmApi() {
2017
return {
2118
auth: auth_1.auth,
22-
config: config_1.default,
19+
config: config_1.config,
2320
getInfo: getInfo_1.getInfo,
2421
getLovedTracks: getLovedTracks_1.getLovedTracks,
2522
getRecentTracks: getRecentTracks_1.getRecentTracks,
@@ -30,7 +27,7 @@ function LastFmApi() {
3027
getWeeklyArtistChart: getWeeklyArtistChart_1.getWeeklyArtistChart,
3128
getWeeklyChartList: getWeeklyChartList_1.getWeeklyChartList,
3229
getWeeklyTrackChart: getWeeklyTrackChart_1.getWeeklyTrackChart,
33-
method: method_1.default,
30+
method: method_1.method,
3431
};
3532
}
3633
exports.default = LastFmApi;

dist/method.d.ts

-32
This file was deleted.

dist/method.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.method = void 0;
34
;
45
;
5-
exports.default = {
6+
exports.method = {
67
auth: 'auth.getToken',
78
user: {
89
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',
10+
getLovedTracks: 'user.getLovedTracks',
11+
getRecentTracks: 'user.getRecentTracks',
12+
getTopAlbums: 'user.getTopAlbums',
13+
getTopArtists: 'user.getTopArtists',
14+
getTopTracks: 'user.getTopTracks',
15+
getWeeklyAlbumChart: 'user.getWeeklyAlbumChart',
16+
getWeeklyArtistChart: 'user.getWeeklyArtistChart',
17+
getWeeklyChartList: 'user.getWeeklyChartList',
18+
getWeeklyTrackChart: 'user.getWeeklyTrackChart',
1819
},
1920
};

dist/request.d.ts

-8
This file was deleted.

dist/request.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1313
};
1414
Object.defineProperty(exports, "__esModule", { value: true });
1515
const cross_fetch_1 = __importDefault(require("cross-fetch"));
16-
const config_1 = __importDefault(require("./config"));
16+
const config_1 = require("./config");
1717
var ErrorResponse;
1818
(function (ErrorResponse) {
1919
ErrorResponse[ErrorResponse["InvalidService"] = 2] = "InvalidService";
@@ -40,9 +40,9 @@ const buildUrl = (options) => {
4040
params.append('period', options.period);
4141
if (options.limit)
4242
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()}`;
43+
params.append('api_key', config_1.config.api_key);
44+
params.append('format', config_1.config.format.json);
45+
return `${config_1.config.base_url}?${params.toString()}`;
4646
};
4747
const request = (options) => __awaiter(void 0, void 0, void 0, function* () {
4848
const url = buildUrl(options);
@@ -52,6 +52,9 @@ const request = (options) => __awaiter(void 0, void 0, void 0, function* () {
5252
},
5353
})
5454
.then((res) => {
55+
if (!res.ok) {
56+
throw new Error(res.statusText);
57+
}
5558
switch (res.status) {
5659
case 200: {
5760
return res.json();
@@ -123,7 +126,7 @@ const request = (options) => __awaiter(void 0, void 0, void 0, function* () {
123126
})
124127
.then((json) => json)
125128
.catch((error) => {
126-
console.log(error);
129+
console.log('🚨 error:', error);
127130
}));
128131
});
129132
exports.default = request;

0 commit comments

Comments
 (0)