Skip to content

Commit

Permalink
Added uwuify and uvuify endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrea committed May 30, 2023
1 parent 667055f commit 0fb2bdb
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/controllers/utils/uvuify.js
Original file line number Diff line number Diff line change
@@ -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)
}
}
27 changes: 27 additions & 0 deletions src/controllers/utils/uwuify.js
Original file line number Diff line number Diff line change
@@ -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)
}
}
2 changes: 2 additions & 0 deletions src/models/schemas/Stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
4 changes: 4 additions & 0 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0fb2bdb

Please sign in to comment.