Skip to content

Commit

Permalink
Merge pull request #45 from WaifuAPI/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
kyrea authored May 30, 2023
2 parents 52c075a + 2f439bd commit e162ec9
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 3 deletions.
4 changes: 2 additions & 2 deletions 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": "3.4.10",
"version": "3.4.11",
"description": "Random API Serving Anime stuff",
"author": "Aeryk",
"private": true,
Expand Down
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 e162ec9

Please sign in to comment.