Skip to content

Commit

Permalink
Merge pull request #21 from AiriAPI/staging
Browse files Browse the repository at this point in the history
Added bunch of action endpoints
  • Loading branch information
kyrea authored Dec 5, 2021
2 parents 40572dc + 69abb59 commit 17d168b
Show file tree
Hide file tree
Showing 130 changed files with 2,533 additions and 3 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": "airi",
"version": "1.1.8",
"version": "1.2.8",
"description": "Random API Serving Anime stuff",
"author": "Aeryk",
"private": true,
Expand Down
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomAngry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Angry = require('../../models/schemas/Angry')

// Get random Anime Angry
module.exports = async function getRandomAngry(req, res, next) {
try {
const [result] = await Angry.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Angry Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomBite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Bite = require('../../models/schemas/Bite')

// Get random Anime Bite
module.exports = async function getRandomBite(req, res, next) {
try {
const [result] = await Bite.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Bite Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomBlush.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Blush = require('../../models/schemas/Blush')

// Get random Anime Blush
module.exports = async function getRandomBlush(req, res, next) {
try {
const [result] = await Blush.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Blush Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomBonk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Bonk = require('../../models/schemas/Bonk')

// Get random Anime Bonk
module.exports = async function getRandomBonk(req, res, next) {
try {
const [result] = await Bonk.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Bonk Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomBored.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Bored = require('../../models/schemas/Bored')

// Get random Anime Bored
module.exports = async function getRandomBored(req, res, next) {
try {
const [result] = await Bored.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Bored Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomBully.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Bully = require('../../models/schemas/Bully')

// Get random Anime Bully
module.exports = async function getRandomBully(req, res, next) {
try {
const [result] = await Bully.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Bully Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomBye.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Bye = require('../../models/schemas/Bye')

// Get random Anime Bye
module.exports = async function getRandomBye(req, res, next) {
try {
const [result] = await Bye.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Bye Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomChase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Chase = require('../../models/schemas/Chase')

// Get random Anime Chase
module.exports = async function getRandomChase(req, res, next) {
try {
const [result] = await Chase.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Chase Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomCheer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Cheer = require('../../models/schemas/Cheer')

// Get random Anime Cheer
module.exports = async function getRandomCheer(req, res, next) {
try {
const [result] = await Cheer.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Cheer Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomCringe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Cringe = require('../../models/schemas/Cringe')

// Get random Anime Cringe
module.exports = async function getRandomCringe(req, res, next) {
try {
const [result] = await Cringe.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Cringe Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomCry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Cry = require('../../models/schemas/Cry')

// Get random Anime Cry
module.exports = async function getRandomCry(req, res, next) {
try {
const [result] = await Cry.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Cry Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomCuddle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Cuddle = require('../../models/schemas/Cuddle')

// Get random Anime Cuddle
module.exports = async function getRandomCuddle(req, res, next) {
try {
const [result] = await Cuddle.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Cuddle Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
28 changes: 28 additions & 0 deletions src/controllers/gifs/randomDab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const createError = require('http-errors')
const requestIp = require('request-ip')
const moment = require('moment')
const Dab = require('../../models/schemas/Dab')

// Get random Anime Dab
module.exports = async function getRandomDab(req, res, next) {
try {
const [result] = await Dab.aggregate([
// Select a random document from the results
{ $sample: { size: 1 } },
{ $project: { __v: 0, _id: 0 } },
])

if (!result) {
return next(createError(404, 'Could not find any Dab Gif'))
}

res.status(200).json(result)
console.log(
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
req
)} to ${req.path} - ${JSON.stringify(req.query)}`
)
} catch (error) {
return next(error)
}
}
Loading

0 comments on commit 17d168b

Please sign in to comment.