deemix-gui/server/src/main.ts

32 lines
766 B
TypeScript
Raw Normal View History

2021-04-21 21:13:47 +02:00
// @ts-ignore
import { Deezer } from 'deezer-js'
console.log("init!")
const dz = new Deezer()
let homeCache: any, chartsCache: any
export async function getHome(){
if (!homeCache){
homeCache = await dz.api.get_chart(0, {limit: 30})
}
return homeCache
}
export async function getCharts(){
if (!chartsCache){
const chartsData = await dz.api.get_countries_charts()
let countries: any[] = []
chartsData.forEach((country: any) => {
countries.push({
title: country.title.replace("Top ", ""),
id: country.id,
picture_small: country.picture_small,
picture_medium: country.picture_medium,
picture_big: country.picture_big,
})
})
chartsCache = {data: countries}
}
return chartsCache
}