Skip to content

Commit

Permalink
added bathc size env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
timhn-bm committed Sep 28, 2024
1 parent f4f4315 commit 8f7fb5f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/api/.env.dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
PORT=3000
DEV=true
BATCH_SIZE=2
10 changes: 9 additions & 1 deletion packages/api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ function retrievePlaylistIdFromUrl(playlistUrl: unknown) {
if (!playlistId) throw new CouldNotRetrievePlaylistIdFromUrl(playlistUrl);
return playlistId;
}

const batchSize = (() => {
const n = Number.parseInt(process.env.BATCH_SIZE || "");
if (Number.isNaN(n)) return 20;
return n;
})();

console.log({ batchSize });
app.get("/deezer-mp3", async (req, res) => {
try {
const { playlistUrl } = req.query;
Expand All @@ -135,7 +143,7 @@ app.get("/deezer-mp3", async (req, res) => {
const playlistId = retrievePlaylistIdFromUrl(playlistUrl);

const songsBatches = await deezerMp3App.downloadPlaylistSongs(playlistId, {
batchSize: 20,
batchSize,
});

console.log({ songsBatches });
Expand Down

0 comments on commit 8f7fb5f

Please sign in to comment.