forked from dbroqua/MusicTopus
Co-authored-by: dbroqua <contact@darkou.fr> Reviewed-on: https://git.darkou.fr/dbroqua/MusicTopus/pulls/57
This commit is contained in:
parent
d473899b20
commit
6320764743
3 changed files with 127 additions and 11 deletions
|
@ -5,13 +5,25 @@ import { discogsToken } from "../config";
|
|||
|
||||
export const getBaseUrl = (req) => `${req.protocol}://${req.get("host")}`;
|
||||
|
||||
export const searchSong = async (q) => {
|
||||
export const searchSong = async (q, format, year, country) => {
|
||||
const dis = new Discogs({ userToken: discogsToken }).database();
|
||||
|
||||
const res = await dis.search({
|
||||
const params = {
|
||||
q,
|
||||
type: "release",
|
||||
});
|
||||
};
|
||||
|
||||
if (format) {
|
||||
params.format = format;
|
||||
}
|
||||
if (year) {
|
||||
params.year = year;
|
||||
}
|
||||
if (country) {
|
||||
params.country = country;
|
||||
}
|
||||
|
||||
const res = await dis.search(params);
|
||||
|
||||
return res;
|
||||
};
|
||||
|
|
|
@ -9,7 +9,12 @@ const router = express.Router();
|
|||
|
||||
router.route("/").get(ensureLoggedIn("/connexion"), async (req, res, next) => {
|
||||
try {
|
||||
const data = await searchSong(req.query.q);
|
||||
const data = await searchSong(
|
||||
req.query.q,
|
||||
req.query.format || null,
|
||||
req.query.year || null,
|
||||
req.query.country || null
|
||||
);
|
||||
|
||||
sendResponse(req, res, data);
|
||||
} catch (err) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue