mirror of
https://github.com/20kaushik02/spotify-manager.git
synced 2026-01-25 06:04:05 +00:00
another day, another correction/improvement/refactor commit
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
const axios = require('axios');
|
||||
|
||||
const { baseAPIURL, accountsAPIURL } = require("../constants");
|
||||
const logger = require('./logger')(module);
|
||||
|
||||
const authInstance = axios.default.create({
|
||||
baseURL: accountsAPIURL,
|
||||
timeout: 20000,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Authorization': 'Basic ' + (Buffer.from(process.env.CLIENT_ID + ':' + process.env.CLIENT_SECRET).toString('base64'))
|
||||
},
|
||||
});
|
||||
|
||||
const axiosInstance = axios.default.create({
|
||||
baseURL: baseAPIURL,
|
||||
timeout: 20000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
});
|
||||
|
||||
axiosInstance.interceptors.request.use(config => {
|
||||
logger.http("API call", {
|
||||
url: config.url,
|
||||
method: config.method,
|
||||
params: config.params ?? {},
|
||||
headers: Object.keys(config.headers),
|
||||
});
|
||||
return config;
|
||||
});
|
||||
|
||||
axiosInstance.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
logger.warn("AxiosError", {
|
||||
error: {
|
||||
name: error.name,
|
||||
code: error.code,
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
},
|
||||
req: error.config,
|
||||
});
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = {
|
||||
authInstance,
|
||||
axiosInstance
|
||||
};
|
||||
@@ -32,7 +32,7 @@ class myGraph {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {type} node
|
||||
* @param {string} node
|
||||
* @returns {string[]}
|
||||
*/
|
||||
getDirectHeads(node) {
|
||||
@@ -40,7 +40,7 @@ class myGraph {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {type} node
|
||||
* @param {string} node
|
||||
* @returns {string[]}
|
||||
*/
|
||||
getDirectTails(node) {
|
||||
|
||||
@@ -28,7 +28,7 @@ const logFormat = printf(({ level, message, label, timestamp, ...meta }) => {
|
||||
}
|
||||
const { stack, ...rest } = meta.error;
|
||||
return `${timestamp} [${label}] ${level}: ${message}${metaFormat(rest)}\n` +
|
||||
`${stack}`;
|
||||
`${stack ?? ''}`;
|
||||
}
|
||||
return `${timestamp} [${label}] ${level}: ${message}${metaFormat(meta)}`;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user