From 90264590cc2b4a879b3f3d29083a27806cad429c Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Tue, 4 Aug 2020 20:27:37 +0200 Subject: [PATCH 01/12] Only send scrobble-request if user is connected --- src/app/components/Providers/LastfmProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/Providers/LastfmProvider.tsx b/src/app/components/Providers/LastfmProvider.tsx index 29e50adb..0ed678b8 100644 --- a/src/app/components/Providers/LastfmProvider.tsx +++ b/src/app/components/Providers/LastfmProvider.tsx @@ -163,7 +163,7 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP }, []); useEffect(() => { - if (mk.mediaItem && mk.mediaItem.item) { + if (connected && mk.mediaItem && mk.mediaItem.item) { scrobble(mk.mediaItem.item); } }, [mk.mediaItem]); From c8a8f9deea7109164ae1f2261f5b678982a1ceb2 Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Tue, 4 Aug 2020 21:07:54 +0200 Subject: [PATCH 02/12] Send updateNowPlaying requests to Last.fm --- .../components/Providers/LastfmProvider.tsx | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/app/components/Providers/LastfmProvider.tsx b/src/app/components/Providers/LastfmProvider.tsx index 0ed678b8..5dca57da 100644 --- a/src/app/components/Providers/LastfmProvider.tsx +++ b/src/app/components/Providers/LastfmProvider.tsx @@ -6,6 +6,11 @@ import Alert from 'react-s-alert'; import withMK from '../../hoc/withMK'; import translate from '../../utils/translations/Translations'; +enum UpdateType { + Scrobble, + UpdateNowPlaying, +} + const apikey = process.env.LASTFM_API_KEY; const secret = process.env.LASTFM_SECRET; @@ -65,17 +70,29 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP return data; } - async function scrobble(item: MusicKit.MediaItem) { - const params = { - 'artist[0]': item.artistName, - 'track[0]': item.title, - 'timestamp[0]': Math.floor(Date.now() / 1000), - 'album[0]': item.albumName, - 'trackNumber[0]': item.trackNumber, - }; + async function sendUpdate(type: UpdateType, item: MusicKit.MediaItem) { + const params = + type === UpdateType.Scrobble + ? { + 'artist[0]': item.artistName, + 'track[0]': item.title, + 'timestamp[0]': Math.floor(Date.now() / 1000), + 'album[0]': item.albumName, + 'trackNumber[0]': item.trackNumber, + } + : { + artist: item.artistName, + track: item.title, + album: item.albumName, + trackNumber: item.trackNumber, + }; try { - await request(true, 'track.scrobble', params); + await request( + true, + type === UpdateType.Scrobble ? 'track.scrobble' : 'track.updateNowPlaying', + params, + ); } catch (e) { if (e.response && e.response.data) { const { data } = e.response; @@ -164,7 +181,8 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP useEffect(() => { if (connected && mk.mediaItem && mk.mediaItem.item) { - scrobble(mk.mediaItem.item); + sendUpdate(UpdateType.UpdateNowPlaying, mk.mediaItem.item); + sendUpdate(UpdateType.Scrobble, mk.mediaItem.item); } }, [mk.mediaItem]); From c969e848d495f751c00daebc1b58b4826f1372ac Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Tue, 4 Aug 2020 21:09:34 +0200 Subject: [PATCH 03/12] Send track duration with scrobble and updateNowPlaying requests --- src/app/components/Providers/LastfmProvider.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/components/Providers/LastfmProvider.tsx b/src/app/components/Providers/LastfmProvider.tsx index 5dca57da..1ee38b9c 100644 --- a/src/app/components/Providers/LastfmProvider.tsx +++ b/src/app/components/Providers/LastfmProvider.tsx @@ -79,12 +79,14 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP 'timestamp[0]': Math.floor(Date.now() / 1000), 'album[0]': item.albumName, 'trackNumber[0]': item.trackNumber, + 'duration[0]': Math.round(item.playbackDuration / 1000), } : { artist: item.artistName, track: item.title, album: item.albumName, trackNumber: item.trackNumber, + duration: Math.round(item.playbackDuration / 1000), }; try { From f06cd32b1bc07fd2dff7dd4a99e49bd9bad032e0 Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Wed, 5 Aug 2020 19:03:58 +0200 Subject: [PATCH 04/12] Scrobble once track has been playing for half of its length --- .../components/Providers/LastfmProvider.tsx | 73 +++++++++++++++++-- 1 file changed, 66 insertions(+), 7 deletions(-) diff --git a/src/app/components/Providers/LastfmProvider.tsx b/src/app/components/Providers/LastfmProvider.tsx index 1ee38b9c..7e5d309b 100644 --- a/src/app/components/Providers/LastfmProvider.tsx +++ b/src/app/components/Providers/LastfmProvider.tsx @@ -1,11 +1,16 @@ import axios, { AxiosRequestConfig } from 'axios'; import md5 from 'js-md5'; import qs from 'qs'; -import React, { ReactNode, useEffect, useState } from 'react'; +import React, { ReactNode, useEffect, useRef, useState } from 'react'; import Alert from 'react-s-alert'; import withMK from '../../hoc/withMK'; +import useMK from '../../hooks/useMK'; import translate from '../../utils/translations/Translations'; +const MIN_SCROBBLE_SONG_LENGTH_MS = 30000; // Last.fm recommends: 30s +const MAX_SCROBBLE_WAIT_MS = 240000; // Last.fm recommends 4m +const SCROBBLE_THRESHOLD = 0.5; // Last.fm recommends: >= 50% + enum UpdateType { Scrobble, UpdateNowPlaying, @@ -38,6 +43,14 @@ export const LastfmContext = React.createContext({ const LastfmProvider: React.FC = ({ children, mk }: LastfmProviderProps) => { const [connected, setConnected] = useState(() => !!getSK()); + const trackStatus = useRef({ + id: '', + playing: false, + playTimeMs: 0, + lastTimestamp: 0, + scrobbleTimeoutId: 0, + hasScrobbled: false, + }); async function request(isWrite: boolean, method: string, callParams = {}, sk = true) { const params: any = { @@ -181,12 +194,10 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP fetchToken(); }, []); - useEffect(() => { - if (connected && mk.mediaItem && mk.mediaItem.item) { - sendUpdate(UpdateType.UpdateNowPlaying, mk.mediaItem.item); - sendUpdate(UpdateType.Scrobble, mk.mediaItem.item); - } - }, [mk.mediaItem]); + useMK({ + mediaItem: MusicKit.Events.mediaItemDidChange, + playbackState: MusicKit.Events.playbackStateDidChange, + }); const state: LastfmProviderValue = { login, @@ -194,6 +205,54 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP connected, }; + if (connected) { + // Cancels upcoming scrobbles and schedules a new scrobble + const scheduleScrobble = () => { + clearTimeout(trackStatus.current.scrobbleTimeoutId); + + if ( + !trackStatus.current.hasScrobbled && + mk.instance.player.isPlaying && + mk.mediaItem && + mk.mediaItem.item.playbackDuration > MIN_SCROBBLE_SONG_LENGTH_MS + ) { + trackStatus.current.scrobbleTimeoutId = window.setTimeout(() => { + trackStatus.current.hasScrobbled = true; + sendUpdate(UpdateType.Scrobble, mk.mediaItem.item); + }, Math.min(MAX_SCROBBLE_WAIT_MS, mk.mediaItem.item.playbackDuration * SCROBBLE_THRESHOLD - trackStatus.current.playTimeMs)); + } + }; + + // New track has started playin + if ( + mk.mediaItem && + trackStatus.current.id !== mk.mediaItem.item.id && + mk.instance.player.isPlaying + ) { + trackStatus.current.id = mk.mediaItem.item.id; + trackStatus.current.playTimeMs = 0; + trackStatus.current.lastTimestamp = performance.now(); + trackStatus.current.hasScrobbled = false; + + sendUpdate(UpdateType.UpdateNowPlaying, mk.mediaItem.item); + scheduleScrobble(); + } + // Track has stopped playing + else if (!mk.instance.player.isPlaying && trackStatus.current.playing) { + trackStatus.current.playTimeMs += performance.now() - trackStatus.current.lastTimestamp; + } + + // Track has started or stopped playing + if (trackStatus.current.playing !== mk.instance.player.isPlaying) { + trackStatus.current.playing = mk.instance.player.isPlaying; + trackStatus.current.lastTimestamp = performance.now(); + + if (mk.instance.player.isPlaying) { + scheduleScrobble(); + } + } + } + return {children}; }; From a4c91f8c16202a7cb1f829c97cc75b867b120ac4 Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Wed, 5 Aug 2020 20:04:41 +0200 Subject: [PATCH 05/12] Scrobble repeating tracks on every repeat --- src/app/components/Providers/LastfmProvider.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/components/Providers/LastfmProvider.tsx b/src/app/components/Providers/LastfmProvider.tsx index 7e5d309b..cc78c86d 100644 --- a/src/app/components/Providers/LastfmProvider.tsx +++ b/src/app/components/Providers/LastfmProvider.tsx @@ -226,7 +226,9 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP // New track has started playin if ( mk.mediaItem && - trackStatus.current.id !== mk.mediaItem.item.id && + (trackStatus.current.id !== mk.mediaItem.item.id || + // Track is being repeated (either manually or automatically) + (mk.instance.player.currentPlaybackProgress === 0 && trackStatus.current.hasScrobbled)) && mk.instance.player.isPlaying ) { trackStatus.current.id = mk.mediaItem.item.id; From 453bfd2c2e9aad5bb36e26eae1403b266559ba4a Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Sat, 8 Aug 2020 11:06:51 +0200 Subject: [PATCH 06/12] Rewrite scrobble-delaying code --- .../components/Providers/LastfmProvider.tsx | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/app/components/Providers/LastfmProvider.tsx b/src/app/components/Providers/LastfmProvider.tsx index cc78c86d..bfa8e3c2 100644 --- a/src/app/components/Providers/LastfmProvider.tsx +++ b/src/app/components/Providers/LastfmProvider.tsx @@ -45,12 +45,11 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP const [connected, setConnected] = useState(() => !!getSK()); const trackStatus = useRef({ id: '', - playing: false, playTimeMs: 0, - lastTimestamp: 0, + playingSince: 0, scrobbleTimeoutId: 0, hasScrobbled: false, - }); + }).current; async function request(isWrite: boolean, method: string, callParams = {}, sk = true) { const params: any = { @@ -206,53 +205,55 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP }; if (connected) { + const track = mk.mediaItem && mk.mediaItem.item; + const player = mk.instance.player; + // Cancels upcoming scrobbles and schedules a new scrobble const scheduleScrobble = () => { - clearTimeout(trackStatus.current.scrobbleTimeoutId); + clearTimeout(trackStatus.scrobbleTimeoutId); if ( - !trackStatus.current.hasScrobbled && - mk.instance.player.isPlaying && - mk.mediaItem && - mk.mediaItem.item.playbackDuration > MIN_SCROBBLE_SONG_LENGTH_MS + !trackStatus.hasScrobbled && + track && + track.playbackDuration > MIN_SCROBBLE_SONG_LENGTH_MS ) { - trackStatus.current.scrobbleTimeoutId = window.setTimeout(() => { - trackStatus.current.hasScrobbled = true; - sendUpdate(UpdateType.Scrobble, mk.mediaItem.item); - }, Math.min(MAX_SCROBBLE_WAIT_MS, mk.mediaItem.item.playbackDuration * SCROBBLE_THRESHOLD - trackStatus.current.playTimeMs)); + trackStatus.scrobbleTimeoutId = window.setTimeout(() => { + trackStatus.hasScrobbled = true; + sendUpdate(UpdateType.Scrobble, track); + }, Math.min(MAX_SCROBBLE_WAIT_MS, track.playbackDuration * SCROBBLE_THRESHOLD - trackStatus.playTimeMs)); } }; - // New track has started playin + // Reset scrobble-status if ( - mk.mediaItem && - (trackStatus.current.id !== mk.mediaItem.item.id || - // Track is being repeated (either manually or automatically) - (mk.instance.player.currentPlaybackProgress === 0 && trackStatus.current.hasScrobbled)) && - mk.instance.player.isPlaying + // New track has started playing + (track && trackStatus.id !== track.id) || + // Track is being repeated + (player.currentPlaybackProgress === 0 && trackStatus.hasScrobbled) ) { - trackStatus.current.id = mk.mediaItem.item.id; - trackStatus.current.playTimeMs = 0; - trackStatus.current.lastTimestamp = performance.now(); - trackStatus.current.hasScrobbled = false; + trackStatus.id = track.id; + trackStatus.playTimeMs = 0; + trackStatus.playingSince = 0; + trackStatus.hasScrobbled = false; - sendUpdate(UpdateType.UpdateNowPlaying, mk.mediaItem.item); - scheduleScrobble(); - } - // Track has stopped playing - else if (!mk.instance.player.isPlaying && trackStatus.current.playing) { - trackStatus.current.playTimeMs += performance.now() - trackStatus.current.lastTimestamp; + sendUpdate(UpdateType.UpdateNowPlaying, track); } - // Track has started or stopped playing - if (trackStatus.current.playing !== mk.instance.player.isPlaying) { - trackStatus.current.playing = mk.instance.player.isPlaying; - trackStatus.current.lastTimestamp = performance.now(); - - if (mk.instance.player.isPlaying) { + // Started playing + if (player.isPlaying) { + if (!trackStatus.playingSince) { + trackStatus.playingSince = performance.now(); scheduleScrobble(); } } + // Stopped playing + else { + if (trackStatus.playingSince) { + trackStatus.playTimeMs += performance.now() - trackStatus.playingSince; + trackStatus.playingSince = 0; + } + clearTimeout(trackStatus.scrobbleTimeoutId); + } } return {children}; From e59303343a1bff6c72883c9bc181a2d529cadad5 Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Sat, 8 Aug 2020 15:05:17 +0200 Subject: [PATCH 07/12] Remove useMK and add event listener to withMK bindings instead --- src/app/components/Providers/LastfmProvider.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/app/components/Providers/LastfmProvider.tsx b/src/app/components/Providers/LastfmProvider.tsx index bfa8e3c2..3c65c8c8 100644 --- a/src/app/components/Providers/LastfmProvider.tsx +++ b/src/app/components/Providers/LastfmProvider.tsx @@ -4,7 +4,6 @@ import qs from 'qs'; import React, { ReactNode, useEffect, useRef, useState } from 'react'; import Alert from 'react-s-alert'; import withMK from '../../hoc/withMK'; -import useMK from '../../hooks/useMK'; import translate from '../../utils/translations/Translations'; const MIN_SCROBBLE_SONG_LENGTH_MS = 30000; // Last.fm recommends: 30s @@ -193,11 +192,6 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP fetchToken(); }, []); - useMK({ - mediaItem: MusicKit.Events.mediaItemDidChange, - playbackState: MusicKit.Events.playbackStateDidChange, - }); - const state: LastfmProviderValue = { login, reset, @@ -261,6 +255,7 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP const bindings = { [MusicKit.Events.mediaItemDidChange]: 'mediaItem', + [MusicKit.Events.playbackStateDidChange]: 'playbackState', }; export default withMK(LastfmProvider, bindings); From af88172c587c27e054c08e49d83eee60dc64bb78 Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Sun, 9 Aug 2020 12:22:09 +0200 Subject: [PATCH 08/12] Send albumArtist with Last.fm requests. Validate Last.fm parameters before sending --- .../components/Providers/LastfmProvider.tsx | 52 +++++++++++++------ 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/src/app/components/Providers/LastfmProvider.tsx b/src/app/components/Providers/LastfmProvider.tsx index 3c65c8c8..b1cec814 100644 --- a/src/app/components/Providers/LastfmProvider.tsx +++ b/src/app/components/Providers/LastfmProvider.tsx @@ -82,23 +82,41 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP } async function sendUpdate(type: UpdateType, item: MusicKit.MediaItem) { - const params = - type === UpdateType.Scrobble - ? { - 'artist[0]': item.artistName, - 'track[0]': item.title, - 'timestamp[0]': Math.floor(Date.now() / 1000), - 'album[0]': item.albumName, - 'trackNumber[0]': item.trackNumber, - 'duration[0]': Math.round(item.playbackDuration / 1000), - } - : { - artist: item.artistName, - track: item.title, - album: item.albumName, - trackNumber: item.trackNumber, - duration: Math.round(item.playbackDuration / 1000), - }; + let metadataAlbumArtist: string | undefined; + { + const metadataItem = item as { + assets?: Array<{ metadata?: { playlistArtistName?: string } }>; + }; + if ( + metadataItem.assets && + metadataItem.assets[0] && + metadataItem.assets[0].metadata && + metadataItem.assets[0].metadata.playlistArtistName + ) { + metadataAlbumArtist = metadataItem.assets[0].metadata.playlistArtistName; + } + } + + const params: { [key: string]: any } = {}; + + function addParameters(parameters: { [key: string]: any }) { + const keySuffix = type === UpdateType.Scrobble ? '[0]' : ''; + for (const key in parameters) { + if (parameters[key]) { + params[key + keySuffix] = parameters[key]; + } + } + } + + addParameters({ + artist: item.artistName, + track: item.title, + timestamp: Math.floor(Date.now() / 1000), + album: item.albumName, + trackNumber: item.trackNumber, + duration: Math.round(item.playbackDuration / 1000), + albumArtist: metadataAlbumArtist, + }); try { await request( From eba4065c8d0933cfc8426a3edf4e5a83749b472c Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Sun, 9 Aug 2020 12:52:44 +0200 Subject: [PATCH 09/12] Use RequestType enum for all Last.fm method strings. Move call-parameters formatting and validation into request(). --- .../components/Providers/LastfmProvider.tsx | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/src/app/components/Providers/LastfmProvider.tsx b/src/app/components/Providers/LastfmProvider.tsx index b1cec814..cedc5118 100644 --- a/src/app/components/Providers/LastfmProvider.tsx +++ b/src/app/components/Providers/LastfmProvider.tsx @@ -10,9 +10,10 @@ const MIN_SCROBBLE_SONG_LENGTH_MS = 30000; // Last.fm recommends: 30s const MAX_SCROBBLE_WAIT_MS = 240000; // Last.fm recommends 4m const SCROBBLE_THRESHOLD = 0.5; // Last.fm recommends: >= 50% -enum UpdateType { - Scrobble, - UpdateNowPlaying, +enum RequestType { + Scrobble = 'track.scrobble', + UpdateNowPlaying = 'track.updateNowPlaying', + GetSession = 'auth.getSession', } const apikey = process.env.LASTFM_API_KEY; @@ -50,9 +51,22 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP hasScrobbled: false, }).current; - async function request(isWrite: boolean, method: string, callParams = {}, sk = true) { + async function request(isWrite: boolean, method: RequestType, callParams = {}, sk = true) { + function getValidatedCallParams(inParams: { [key: string]: any }): object { + const formattedParams: { [key: string]: any } = {}; + const keySuffix = method === RequestType.Scrobble ? '[0]' : ''; + + for (const key in inParams) { + if (inParams[key]) { + formattedParams[key + keySuffix] = inParams[key]; + } + } + + return formattedParams; + } + const params: any = { - ...callParams, + ...getValidatedCallParams(callParams), method, api_key: apikey, }; @@ -81,7 +95,7 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP return data; } - async function sendUpdate(type: UpdateType, item: MusicKit.MediaItem) { + async function sendUpdate(type: RequestType, item: MusicKit.MediaItem) { let metadataAlbumArtist: string | undefined; { const metadataItem = item as { @@ -97,18 +111,7 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP } } - const params: { [key: string]: any } = {}; - - function addParameters(parameters: { [key: string]: any }) { - const keySuffix = type === UpdateType.Scrobble ? '[0]' : ''; - for (const key in parameters) { - if (parameters[key]) { - params[key + keySuffix] = parameters[key]; - } - } - } - - addParameters({ + const params = { artist: item.artistName, track: item.title, timestamp: Math.floor(Date.now() / 1000), @@ -116,14 +119,10 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP trackNumber: item.trackNumber, duration: Math.round(item.playbackDuration / 1000), albumArtist: metadataAlbumArtist, - }); + }; try { - await request( - true, - type === UpdateType.Scrobble ? 'track.scrobble' : 'track.updateNowPlaying', - params, - ); + await request(true, type, params); } catch (e) { if (e.response && e.response.data) { const { data } = e.response; @@ -162,7 +161,7 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP token, }; - const data = await request(true, 'auth.getSession', params, false); + const data = await request(true, RequestType.GetSession, params, false); localStorage.setItem(SK_STORAGE_KEY, data.session.key); @@ -231,7 +230,7 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP ) { trackStatus.scrobbleTimeoutId = window.setTimeout(() => { trackStatus.hasScrobbled = true; - sendUpdate(UpdateType.Scrobble, track); + sendUpdate(RequestType.Scrobble, track); }, Math.min(MAX_SCROBBLE_WAIT_MS, track.playbackDuration * SCROBBLE_THRESHOLD - trackStatus.playTimeMs)); } }; @@ -248,7 +247,7 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP trackStatus.playingSince = 0; trackStatus.hasScrobbled = false; - sendUpdate(UpdateType.UpdateNowPlaying, track); + sendUpdate(RequestType.UpdateNowPlaying, track); } // Started playing From 8ae401e74ce90442a6c765bbe486c31d2e90d2cf Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Sun, 9 Aug 2020 21:16:53 +0200 Subject: [PATCH 10/12] Refactor album-artist handling LastfmProvider code --- .../components/Providers/LastfmProvider.tsx | 56 +++++++++---------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/src/app/components/Providers/LastfmProvider.tsx b/src/app/components/Providers/LastfmProvider.tsx index cedc5118..eaaa8a28 100644 --- a/src/app/components/Providers/LastfmProvider.tsx +++ b/src/app/components/Providers/LastfmProvider.tsx @@ -10,7 +10,7 @@ const MIN_SCROBBLE_SONG_LENGTH_MS = 30000; // Last.fm recommends: 30s const MAX_SCROBBLE_WAIT_MS = 240000; // Last.fm recommends 4m const SCROBBLE_THRESHOLD = 0.5; // Last.fm recommends: >= 50% -enum RequestType { +enum ApiMethod { Scrobble = 'track.scrobble', UpdateNowPlaying = 'track.updateNowPlaying', GetSession = 'auth.getSession', @@ -51,22 +51,9 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP hasScrobbled: false, }).current; - async function request(isWrite: boolean, method: RequestType, callParams = {}, sk = true) { - function getValidatedCallParams(inParams: { [key: string]: any }): object { - const formattedParams: { [key: string]: any } = {}; - const keySuffix = method === RequestType.Scrobble ? '[0]' : ''; - - for (const key in inParams) { - if (inParams[key]) { - formattedParams[key + keySuffix] = inParams[key]; - } - } - - return formattedParams; - } - + async function request(isWrite: boolean, method: ApiMethod, callParams = {}, sk = true) { const params: any = { - ...getValidatedCallParams(callParams), + ...callParams, method, api_key: apikey, }; @@ -95,8 +82,17 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP return data; } - async function sendUpdate(type: RequestType, item: MusicKit.MediaItem) { - let metadataAlbumArtist: string | undefined; + async function sendUpdate(type: ApiMethod, item: MusicKit.MediaItem) { + const params: { [key: string]: any } = { + artist: item.artistName, + track: item.title, + timestamp: Math.floor(Date.now() / 1000), + album: item.albumName, + trackNumber: item.trackNumber, + duration: Math.round(item.playbackDuration / 1000), + }; + + // Find the album-artist and add it to params { const metadataItem = item as { assets?: Array<{ metadata?: { playlistArtistName?: string } }>; @@ -107,19 +103,17 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP metadataItem.assets[0].metadata && metadataItem.assets[0].metadata.playlistArtistName ) { - metadataAlbumArtist = metadataItem.assets[0].metadata.playlistArtistName; + params.albumArtist = metadataItem.assets[0].metadata.playlistArtistName; } } - const params = { - artist: item.artistName, - track: item.title, - timestamp: Math.floor(Date.now() / 1000), - album: item.albumName, - trackNumber: item.trackNumber, - duration: Math.round(item.playbackDuration / 1000), - albumArtist: metadataAlbumArtist, - }; + // Add '[0]' suffix to params when a scrobble-request is made + if (type === ApiMethod.Scrobble) { + for (const key of Object.keys(params)) { + params[key + '[0]'] = params[key]; + delete params[key]; + } + } try { await request(true, type, params); @@ -161,7 +155,7 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP token, }; - const data = await request(true, RequestType.GetSession, params, false); + const data = await request(true, ApiMethod.GetSession, params, false); localStorage.setItem(SK_STORAGE_KEY, data.session.key); @@ -230,7 +224,7 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP ) { trackStatus.scrobbleTimeoutId = window.setTimeout(() => { trackStatus.hasScrobbled = true; - sendUpdate(RequestType.Scrobble, track); + sendUpdate(ApiMethod.Scrobble, track); }, Math.min(MAX_SCROBBLE_WAIT_MS, track.playbackDuration * SCROBBLE_THRESHOLD - trackStatus.playTimeMs)); } }; @@ -247,7 +241,7 @@ const LastfmProvider: React.FC = ({ children, mk }: LastfmP trackStatus.playingSince = 0; trackStatus.hasScrobbled = false; - sendUpdate(RequestType.UpdateNowPlaying, track); + sendUpdate(ApiMethod.UpdateNowPlaying, track); } // Started playing From 2ebe25140d6b65d8be6fdcf4606f185e9ad9b9af Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Mon, 10 Aug 2020 19:34:13 +0200 Subject: [PATCH 11/12] Update CircleCI Node version and node-sass package version --- .circleci/config.yml | 2 +- package.json | 2 +- yarn.lock | 157 ++++++++++++++++++++++++++++--------------- 3 files changed, 104 insertions(+), 57 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 761be30a..448b3c2b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 executors: musish-executor: docker: - - image: circleci/node:8 + - image: circleci/node:14 working_directory: /tmp/workspace jobs: diff --git a/package.json b/package.json index bbd58883..596c16b2 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "js-md5": "^0.7.3", "lodash": "^4.17.13", "mousetrap": "^1.6.2", - "node-sass": "^4.10.0", + "node-sass": "^4.14.1", "normalize.css": "^8.0.1", "prop-types": "^15.6.2", "qs": "^6.7.0", diff --git a/yarn.lock b/yarn.lock index f6866eaa..4fc96fbb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1137,11 +1137,16 @@ ansi-regex@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" +ansi-regex@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" + integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" -ansi-styles@^3.2.1: +ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" dependencies: @@ -1640,10 +1645,6 @@ camelcase@^2.0.0, camelcase@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" -camelcase@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" - camelcase@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" @@ -1783,7 +1784,7 @@ clean-webpack-plugin@^0.1.19: dependencies: rimraf "^2.6.1" -cliui@^3.0.3, cliui@^3.2.0: +cliui@^3.0.3: version "3.2.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" dependencies: @@ -1799,6 +1800,15 @@ cliui@^4.0.0: strip-ansi "^4.0.0" wrap-ansi "^2.0.0" +cliui@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" + integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== + dependencies: + string-width "^3.1.0" + strip-ansi "^5.2.0" + wrap-ansi "^5.1.0" + clone-deep@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-2.0.2.tgz#00db3a1e173656730d1188c3d6aced6d7ea97713" @@ -2637,6 +2647,11 @@ elliptic@^6.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.0" +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + emojis-list@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" @@ -3264,6 +3279,11 @@ get-caller-file@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" +get-caller-file@^2.0.1: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" @@ -4341,10 +4361,6 @@ lodash.assign@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" -lodash.clonedeep@^4.3.2: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" - lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" @@ -4358,11 +4374,6 @@ lodash.merge@^4.6.1: resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash.mergewith@^4.6.0: - version "4.6.2" - resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz#617121f89ac55f59047c7aec1ccd6654c6590f55" - integrity sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ== - lodash.tail@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lodash.tail/-/lodash.tail-4.1.1.tgz#d2333a36d9e7717c8ad2f7cacafec7c32b444664" @@ -4380,6 +4391,11 @@ lodash@^3.2.0: version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" +lodash@^4.17.15: + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== + lodash@~2.4.1: version "2.4.2" resolved "https://registry.yarnpkg.com/lodash/-/lodash-2.4.2.tgz#fadd834b9683073da179b3eae6d9c0d15053f73e" @@ -4703,7 +4719,12 @@ musickit-typescript@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/musickit-typescript/-/musickit-typescript-1.2.4.tgz#d055117e2c897c4ebc570f0d969ad31649744837" -nan@^2.10.0, nan@^2.9.2: +nan@^2.13.2: + version "2.14.1" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01" + integrity sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw== + +nan@^2.9.2: version "2.12.1" resolved "https://registry.yarnpkg.com/nan/-/nan-2.12.1.tgz#7b1aa193e9aa86057e3c7bbd0ac448e770925552" @@ -4836,9 +4857,10 @@ node-rest-client@^1.5.1: debug "~2.2.0" xml2js ">=0.2.4" -node-sass@^4.10.0: - version "4.11.0" - resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.11.0.tgz#183faec398e9cbe93ba43362e2768ca988a6369a" +node-sass@^4.14.1: + version "4.14.1" + resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.14.1.tgz#99c87ec2efb7047ed638fb4c9db7f3a42e2217b5" + integrity sha512-sjCuOlvGyCJS40R8BscF5vhVlQjNN069NtQ1gSxyK1u9iqvn6tf7O1R4GNowVZfiZUCRt5MmMs1xd+4V/7Yr0g== dependencies: async-foreach "^0.1.3" chalk "^1.1.1" @@ -4847,16 +4869,14 @@ node-sass@^4.10.0: get-stdin "^4.0.1" glob "^7.0.3" in-publish "^2.0.0" - lodash.assign "^4.2.0" - lodash.clonedeep "^4.3.2" - lodash.mergewith "^4.6.0" + lodash "^4.17.15" meow "^3.7.0" mkdirp "^0.5.1" - nan "^2.10.0" + nan "^2.13.2" node-gyp "^3.8.0" npmlog "^4.0.0" request "^2.88.0" - sass-graph "^2.2.4" + sass-graph "2.2.5" stdout-stream "^1.4.0" "true-case-path" "^1.0.2" @@ -6246,6 +6266,11 @@ require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== + require-relative@^0.8.7: version "0.8.7" resolved "https://registry.yarnpkg.com/require-relative/-/require-relative-0.8.7.tgz#7999539fc9e047a37928fa196f8e1563dabd36de" @@ -6381,14 +6406,15 @@ safe-regex@^1.1.0: version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" -sass-graph@^2.2.4: - version "2.2.4" - resolved "https://registry.yarnpkg.com/sass-graph/-/sass-graph-2.2.4.tgz#13fbd63cd1caf0908b9fd93476ad43a51d1e0b49" +sass-graph@2.2.5: + version "2.2.5" + resolved "https://registry.yarnpkg.com/sass-graph/-/sass-graph-2.2.5.tgz#a981c87446b8319d96dce0671e487879bd24c2e8" + integrity sha512-VFWDAHOe6mRuT4mZRd4eKE+d8Uedrk6Xnh7Sh9b4NGufQLQjOrvf/MQoOdx+0s92L89FeyUUNfU597j/3uNpag== dependencies: glob "^7.0.0" lodash "^4.0.0" scss-tokenizer "^0.2.3" - yargs "^7.0.0" + yargs "^13.3.2" sass-loader@^7.1.0: version "7.1.0" @@ -6815,7 +6841,7 @@ stream-to@~0.2.0: version "0.2.2" resolved "https://registry.yarnpkg.com/stream-to/-/stream-to-0.2.2.tgz#84306098d85fdb990b9fa300b1b3ccf55e8ef01d" -string-width@^1.0.1, string-width@^1.0.2: +string-width@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" dependencies: @@ -6830,6 +6856,15 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" +string-width@^3.0.0, string-width@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" + string.prototype.trim@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz#d04de2c89e137f4d7d206f086b5ed2fae6be8cea" @@ -6866,6 +6901,13 @@ strip-ansi@^4.0.0: dependencies: ansi-regex "^3.0.0" +strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" + integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== + dependencies: + ansi-regex "^4.1.0" + strip-bom@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" @@ -7589,10 +7631,6 @@ whatwg-fetch@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb" -which-module@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" - which-module@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" @@ -7626,6 +7664,15 @@ wrap-ansi@^2.0.0: string-width "^1.0.1" strip-ansi "^3.0.1" +wrap-ansi@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" + integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== + dependencies: + ansi-styles "^3.2.0" + string-width "^3.0.0" + strip-ansi "^5.0.0" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" @@ -7698,11 +7745,13 @@ yargs-parser@^12.0.0: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-5.0.0.tgz#275ecf0d7ffe05c77e64e7c86e4cd94bf0e1228a" +yargs-parser@^13.1.2: + version "13.1.2" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" + integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== dependencies: - camelcase "^3.0.0" + camelcase "^5.0.0" + decamelize "^1.2.0" yargs-parser@^9.0.2: version "9.0.2" @@ -7761,6 +7810,22 @@ yargs@^12.0.1, yargs@^12.0.4, yargs@^12.0.5: y18n "^3.2.1 || ^4.0.0" yargs-parser "^11.1.1" +yargs@^13.3.2: + version "13.3.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" + integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== + dependencies: + cliui "^5.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^13.1.2" + yargs@^3.31.0: version "3.32.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995" @@ -7773,24 +7838,6 @@ yargs@^3.31.0: window-size "^0.1.4" y18n "^3.2.0" -yargs@^7.0.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-7.1.0.tgz#6ba318eb16961727f5d284f8ea003e8d6154d0c8" - dependencies: - camelcase "^3.0.0" - cliui "^3.2.0" - decamelize "^1.1.1" - get-caller-file "^1.0.1" - os-locale "^1.4.0" - read-pkg-up "^1.0.1" - require-directory "^2.1.1" - require-main-filename "^1.0.1" - set-blocking "^2.0.0" - string-width "^1.0.2" - which-module "^1.0.0" - y18n "^3.2.1" - yargs-parser "^5.0.0" - yauzl@2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005" From 73f54c5d120aba881988c9c2eb7c201e94cb9963 Mon Sep 17 00:00:00 2001 From: napieralla <56790644+napieralla@users.noreply.github.com> Date: Mon, 10 Aug 2020 22:18:09 +0200 Subject: [PATCH 12/12] Upgrade backend's AWS Lambda Node.js runtime to v12 --- src/backend/serverless.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/serverless.yml b/src/backend/serverless.yml index 25f65814..3e73a9ee 100644 --- a/src/backend/serverless.yml +++ b/src/backend/serverless.yml @@ -5,7 +5,7 @@ custom: provider: name: aws - runtime: nodejs8.10 + runtime: nodejs12.x stage: ${self:custom.secrets.NODE_ENV} region: us-east-1