Add All Seasons Services - v2.1.0

pull/1/head
Jéluchu 5 years ago
parent 97a6c81341
commit 9084d2b023

@ -1,6 +1,6 @@
{
"name": "aruppi",
"version": "2.0.1",
"version": "2.1.0",
"description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app",
"main": "./src/api/api.js",
"scripts": {
@ -40,6 +40,7 @@
"type": "git",
"url": "https://github.com/aruppi/aruppi-api.git"
},
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"cheerio": "^1.0.0-rc.3",

@ -143,6 +143,24 @@ const season = async (year, type) =>{
};
const allSeasons = async () =>{
const data = await html(`${BASE_JIKAN}season/archive`).json();
let body = data.archive;
const promises = []
body.map(doc =>{
promises.push({
year: doc.year,
seasons: doc.seasons,
});
});
return promises;
};
const getLastEpisodes = async () =>{
const data = await html(`${BASE_ANIMEFLV_JELU}LatestEpisodesAdded`).json();
@ -369,6 +387,7 @@ module.exports = {
getAnitakume,
getNews,
season,
allSeasons,
getLastEpisodes,
getSpecials,
getMoreInfo,

@ -17,6 +17,7 @@ router.get('/', (req, res) => {
'Anitakume': '/api/v2/anitakume',
'News': '/api/v2/news',
'Season': '/api/v2/season/:year/:type',
'All Seasons': '/api/v2/allSeasons',
'LastEpisodes': '/api/v2/lastEpisodes',
'Movies': '/api/v2/movies/:type/:page',
'Ovas': '/api/v2/ovas/:type/:page',

@ -122,6 +122,23 @@ router.get('/season/:year/:type' , (req, res) =>{
});
router.get('/allSeasons' , (req, res) =>{
api.allSeasons()
.then(archive =>{
if (archive.length > 0) {
res.status(200).json({
archive
});
} else (
res.status(500).json({ message: 'Aruppi lost in the shell'})
)
}).catch((err) =>{
console.error(err);
});
});
router.get('/lastEpisodes' , (req, res) =>{
api.getLastEpisodes()

Loading…
Cancel
Save