diff --git a/package-lock.json b/package-lock.json index 4ab6ad4..6e6aaf6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "waifu.it", - "version": "4.5.15", + "version": "4.6.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index e42b0c8..5f2fa35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "waifu.it", - "version": "4.5.15", + "version": "4.6.0", "description": "Random API Serving Anime stuff", "author": "Aeryk", "private": true, diff --git a/src/controllers/v4/images/waifu.js b/src/controllers/v4/images/waifu.js index b62014c..785cc49 100644 --- a/src/controllers/v4/images/waifu.js +++ b/src/controllers/v4/images/waifu.js @@ -44,7 +44,14 @@ const getWaifu = async (req, res, next) => { if (anime) { const sanitizedAnime = _.escapeRegExp(anime.trim()); - filter['media.nodes[0].title.userPreferred'] = { $regex: new RegExp(sanitizedAnime, 'i') }; // Case-insensitive regex match for anime name + filter['media.nodes'] = { + $elemMatch: { + $or: [ + { 'title.userPreferred': { $regex: new RegExp(sanitizedAnime, 'i') } }, + { synonyms: { $regex: new RegExp(sanitizedAnime, 'i') } }, + ], + }, + }; } /** diff --git a/src/controllers/v4/textUtilities/owoify.js b/src/controllers/v4/textUtilities/owoify.js index 15213b4..639096f 100644 --- a/src/controllers/v4/textUtilities/owoify.js +++ b/src/controllers/v4/textUtilities/owoify.js @@ -1,6 +1,7 @@ import createError from 'http-errors'; import owoify from 'owoify-js'; import Stats from '../../../models/schemas/Stat.js'; +const generateText = owoify.default; /** * Gets the Owofied version of the provided text and updates system statistics. @@ -38,7 +39,7 @@ const getOwoifyText = async (req, res, next) => { * @property {String} text - The Owofied version of the provided text. */ res.status(200).json({ - text: owoify(text), + text: generateText(text), }); /** diff --git a/src/controllers/v4/textUtilities/quote.js b/src/controllers/v4/textUtilities/quote.js index a675a96..ba21b8f 100644 --- a/src/controllers/v4/textUtilities/quote.js +++ b/src/controllers/v4/textUtilities/quote.js @@ -15,14 +15,23 @@ const getQuote = async (req, res, next) => { * Extract character parameter from the query * @type {string} */ - const { character } = req.query; + const { character, anime } = req.query; /** * Create a filter object based on the optional character parameter * @type {Object} */ - const filter = character ? { author: character } : {}; - + /** + * Create a filter object based on the optional character and anime parameters + * @type {Object} + */ + const filter = {}; + if (character) { + filter.author = { $regex: character, $options: 'i' }; + } + if (anime) { + filter.anime = { $regex: anime, $options: 'i' }; + } /** * Aggregate to match the filter, select a random quote, and project excluding version field * @type {Array} diff --git a/src/controllers/v4/textUtilities/uvuify.js b/src/controllers/v4/textUtilities/uvuify.js index 1bfe5a9..0b5121e 100644 --- a/src/controllers/v4/textUtilities/uvuify.js +++ b/src/controllers/v4/textUtilities/uvuify.js @@ -1,6 +1,7 @@ import createError from 'http-errors'; import uvuify from 'owoify-js'; import Stats from '../../../models/schemas/Stat.js'; +const generateText = uvuify.default; /** * Route handler to get UvUified text. @@ -20,7 +21,7 @@ const getUvuifyText = async (req, res, next) => { // UvUify the text and send the response res.status(200).json({ - text: uvuify(text), + text: generateText(text, 'uvu'), }); // Increment the UvUify counter in the stats diff --git a/src/controllers/v4/textUtilities/uwuify.js b/src/controllers/v4/textUtilities/uwuify.js index 3b79d7a..3ead9e2 100644 --- a/src/controllers/v4/textUtilities/uwuify.js +++ b/src/controllers/v4/textUtilities/uwuify.js @@ -1,6 +1,7 @@ import createError from 'http-errors'; import uwuify from 'owoify-js'; import Stats from '../../../models/schemas/Stat.js'; +const generateText = uwuify.default; /** * Route handler to get UwUified text. @@ -20,7 +21,7 @@ const getUwuifyText = async (req, res, next) => { // UwUify the text and send the response res.status(200).json({ - text: uwuify(text), + text: generateText(text, 'uwu'), }); // Increment the UwUify counter in the stats