From 0fb2bdbf7678eb664054cdf69910cae0328c3e9d Mon Sep 17 00:00:00 2001 From: kyrea Date: Tue, 30 May 2023 13:11:46 +0530 Subject: [PATCH 1/2] Added uwuify and uvuify endpoints --- src/controllers/utils/uvuify.js | 27 +++++++++++++++++++++++++++ src/controllers/utils/uwuify.js | 27 +++++++++++++++++++++++++++ src/models/schemas/Stat.js | 2 ++ src/routes.js | 4 ++++ 4 files changed, 60 insertions(+) create mode 100644 src/controllers/utils/uvuify.js create mode 100644 src/controllers/utils/uwuify.js diff --git a/src/controllers/utils/uvuify.js b/src/controllers/utils/uvuify.js new file mode 100644 index 0000000..2245ac8 --- /dev/null +++ b/src/controllers/utils/uvuify.js @@ -0,0 +1,27 @@ +const createError = require('http-errors') +const uwuify = require('owoify-js') +const Stats = require('../../models/schemas/Stat') + +module.exports = async function getOwofiyText(req, res, next) { + try { + const { text } = req.query + + if (!text) { + return next(createError(404, 'Invalid text input.')) + } + res.status(200).json({ + text: uwuify(text), + }) + + return await Stats.findOneAndUpdate( + { _id: 'systemstats' }, + { $inc: { uwuify: 1 } } + ) + } catch (error) { + await Stats.findOneAndUpdate( + { _id: 'systemstats' }, + { $inc: { failed_requests: 1 } } + ) + return next(error) + } +} \ No newline at end of file diff --git a/src/controllers/utils/uwuify.js b/src/controllers/utils/uwuify.js new file mode 100644 index 0000000..9e5f9e2 --- /dev/null +++ b/src/controllers/utils/uwuify.js @@ -0,0 +1,27 @@ +const createError = require('http-errors') +const uvuify = require('owoify-js') +const Stats = require('../../models/schemas/Stat') + +module.exports = async function getOwofiyText(req, res, next) { + try { + const { text } = req.query + + if (!text) { + return next(createError(404, 'Invalid text input.')) + } + res.status(200).json({ + text: uvuify(text), + }) + + return await Stats.findOneAndUpdate( + { _id: 'systemstats' }, + { $inc: { uvuify: 1 } } + ) + } catch (error) { + await Stats.findOneAndUpdate( + { _id: 'systemstats' }, + { $inc: { failed_requests: 1 } } + ) + return next(error) + } +} \ No newline at end of file diff --git a/src/models/schemas/Stat.js b/src/models/schemas/Stat.js index 2a54251..aeb1c7b 100644 --- a/src/models/schemas/Stat.js +++ b/src/models/schemas/Stat.js @@ -42,6 +42,8 @@ const StatSchema = new Schema({ bye: { type: Number, default: 0 }, chase: { type: Number, default: 0 }, owoify: { type: Number, default: 0 }, + uwuify: { type: Number, default: 0 }, + uvuify: { type: Number, default: 0 }, cheer: { type: Number, default: 0 }, client: { type: Number, default: 0 }, cringe: { type: Number, default: 0 }, diff --git a/src/routes.js b/src/routes.js index d485b18..dc35781 100644 --- a/src/routes.js +++ b/src/routes.js @@ -4,6 +4,8 @@ const authHandler = require('./handlers/auth/index') const randomFacts = require('./controllers/facts/randomFacts') const getAllTags = require('./controllers/utils/listTags') const getOwoify = require('./controllers/utils/owoify') +const getUwuify = require('./controllers/utils/uwuify') +const getUvuify = require('./controllers/utils/uvuify') const randomWaifus = require('./controllers/waifus/randomWaifus') const randomPasswords = require('./controllers/utils/randomPassword') const randomQuotes = require('./controllers/quotes/randomQuotes') @@ -94,6 +96,8 @@ router.get('/api/waifu', Limiter, authHandler, randomWaifus) router.get('/api/password', Limiter, authHandler, randomPasswords) router.get('/api/alltags', Limiter, authHandler, getAllTags) router.get('/api/owoify', Limiter, authHandler, getOwoify) +router.get('/api/uwuify', Limiter, authHandler, getUwuify) +router.get('/api/uvuify', Limiter, authHandler, getUvuify) // Random Quote Endpoint router.get('/api/quote', Limiter, authHandler, randomQuotes) From 2f439bdebca6300820a5481a72879421f0ffca2f Mon Sep 17 00:00:00 2001 From: kyrea Date: Tue, 30 May 2023 13:13:47 +0530 Subject: [PATCH 2/2] Bumped the version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 09a92ef..de6afbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "waifu.it", - "version": "3.4.10", + "version": "3.4.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "waifu.it", - "version": "3.4.10", + "version": "3.4.11", "license": "AGPLv3", "dependencies": { "chalk": "^4.1.1", diff --git a/package.json b/package.json index d911a3a..47001b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "waifu.it", - "version": "3.4.10", + "version": "3.4.11", "description": "Random API Serving Anime stuff", "author": "Aeryk", "private": true,