been a while

This commit is contained in:
2023-09-24 19:27:04 -07:00
parent d4a6424fd0
commit 3f4bc3b8e9
7 changed files with 565 additions and 321 deletions

View File

@@ -65,13 +65,18 @@ const callback = async (req, res) => {
const response = await authInstance.post('/api/token', authPayload);
if (response.status === 200) {
logger.info('New login.');
req.session.accessToken = response.data.access_token;
req.session.refreshToken = response.data.refresh_token;
req.session.cookie.maxAge = response.data.expires_in * 1000;
req.session.save((err) => { if (err) throw err; });
req.session.save((err) => {
if (err) {
logger.error("redis session save error", { sessionError: err })
throw err;
}
});
logger.info('New login.')
return res.status(200).send({
message: "Login successful",
});

View File

@@ -10,6 +10,8 @@ const { axiosInstance } = require('../axios');
*/
const getUserPlaylists = async (req, res) => {
try {
let playlists = {};
// get first 50
const response = await axiosInstance.get(
"/me/playlists",
@@ -24,8 +26,6 @@ const getUserPlaylists = async (req, res) => {
}
);
let playlists = {};
playlists.items = response.data.items.map((playlist) => {
return {
name: playlist.name,
@@ -42,10 +42,10 @@ const getUserPlaylists = async (req, res) => {
playlists.total = response.data.total;
playlists.next = response.data.next;
// keep getting batches of 50 more till exhausted
// keep getting batches of 50 till exhausted
while (playlists.next) {
const nextResponse = await axiosInstance.get(
playlists.next, // absolute URL which has params
playlists.next, // absolute URL from previous response which has offset and limit params
{
headers: {
...req.authHeader