diff --git a/package.json b/package.json index 86362d8..b170bef 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/api/api.js b/src/api/api.js index 2cbaee0..08e497b 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -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, diff --git a/src/api/index.js b/src/api/index.js index 54e1d78..49ec561 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -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', diff --git a/src/api/routes/index.js b/src/api/routes/index.js index 02af8e1..b2dbfc8 100644 --- a/src/api/routes/index.js +++ b/src/api/routes/index.js @@ -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()