Skip to content

Commit

Permalink
Merge pull request #58 from WaifuAPI/staging
Browse files Browse the repository at this point in the history
Upcoming update
  • Loading branch information
kyrea committed May 20, 2024
2 parents ef8da08 + 7d371c4 commit 8207f90
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
9 changes: 8 additions & 1 deletion src/controllers/v4/images/waifu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') } },
],
},
};
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/v4/textUtilities/owoify.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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),
});

/**
Expand Down
15 changes: 12 additions & 3 deletions src/controllers/v4/textUtilities/quote.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object>}
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/v4/textUtilities/uvuify.js
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/v4/textUtilities/uwuify.js
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down

0 comments on commit 8207f90

Please sign in to comment.