Skip to content

Commit a33323c

Browse files
authored
Merge pull request #43 from WaifuAPI/staging
Staging
2 parents f216837 + 44b8840 commit a33323c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+441
-1054
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"mongodb": "^3.6.9",
3030
"mongoose": "^5.13.9",
3131
"ora": "^5.4.1",
32+
"owoify-js": "^2.0.0",
3233
"path": "^0.12.7",
3334
"request-ip": "^2.1.3",
3435
"winston": "^3.3.3",

src/app.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,6 @@ app.set('trust proxy', 1)
2020

2121
// Logger
2222
if (process.env.LOGGER === 'true') {
23-
/* Winson logger */
24-
25-
// const transport = new winston.transports.DailyRotateFile({
26-
// filename: 'logs/requests/%DATE%.log',
27-
// datePattern: 'DD-MM-YYYY',
28-
// zippedArchive: false,
29-
// maxSize: '20m',
30-
// maxFiles: '14d',
31-
// })
32-
33-
// app
34-
// .use
35-
// /* Winson logger */
36-
37-
// // expressWinston.logger({
38-
// // transports: [transport],
39-
// // format: winston.format.combine(
40-
// // winston.format.colorize(),
41-
// // winston.format.json()
42-
// // ),
43-
// // meta: true,
44-
// // msg(req, res) {
45-
// // return `${res.statusCode} - ${req.method} - ${
46-
// // res.responseTime
47-
// // }ms - IP: ${req.ip} IPs: ${requestIp.getClientIp(req)}`
48-
// // },
49-
// // expressFormat: true,
50-
// // colorize: false,
51-
// // ignoreRoute(req, res) {
52-
// // return false
53-
// // },
54-
// // })
55-
// ()
5623
app.use(ipLogger)
5724
}
5825

src/controllers/facts/randomFacts.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const createError = require('http-errors')
2-
const requestIp = require('request-ip')
3-
const moment = require('moment')
42
const Facts = require('../../models/schemas/Facts')
53
const tagsFilter = require('../../utils/tagsFilter')
64
const lengthFilter = require('../../utils/lengthFilter')
@@ -34,19 +32,12 @@ module.exports = async function getRandomFact(req, res, next) {
3432
}
3533

3634
res.status(200).json(result)
37-
console.log(
38-
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
39-
req
40-
)} to ${req.path} - ${JSON.stringify(req.query)}`
41-
)
42-
await Stats.findOneAndUpdate (
43-
{ _id: "systemstats" },
44-
{ $inc: { facts: 1 } },
45-
)
35+
36+
await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { facts: 1 } })
4637
} catch (error) {
47-
await Stats.findOneAndUpdate (
48-
{ _id: "systemstats" },
49-
{ $inc: { failed_requests: 1 } },
38+
await Stats.findOneAndUpdate(
39+
{ _id: 'systemstats' },
40+
{ $inc: { failed_requests: 1 } }
5041
)
5142
return next(error)
5243
}

src/controllers/gifs/randomAngry.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const createError = require('http-errors')
2-
const requestIp = require('request-ip')
3-
const moment = require('moment')
42
const Angry = require('../../models/schemas/Angry')
53
const Stats = require('../../models/schemas/Stat')
64

@@ -18,19 +16,12 @@ module.exports = async function getRandomAngry(req, res, next) {
1816
}
1917

2018
res.status(200).json(result)
21-
console.log(
22-
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
23-
req
24-
)} to ${req.path} - ${JSON.stringify(req.query)}`
25-
)
26-
await Stats.findOneAndUpdate (
27-
{ _id: "systemstats" },
28-
{ $inc: { angry: 1 } },
29-
)
19+
20+
await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { angry: 1 } })
3021
} catch (error) {
31-
await Stats.findOneAndUpdate (
32-
{ _id: "systemstats" },
33-
{ $inc: { failed_requests: 1 } },
22+
await Stats.findOneAndUpdate(
23+
{ _id: 'systemstats' },
24+
{ $inc: { failed_requests: 1 } }
3425
)
3526
return next(error)
3627
}

src/controllers/gifs/randomBaka.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const createError = require('http-errors')
2-
const requestIp = require('request-ip')
3-
const moment = require('moment')
42
const Baka = require('../../models/schemas/Baka')
53
const Stats = require('../../models/schemas/Stat')
64

@@ -18,19 +16,12 @@ module.exports = async function getRandomBaka(req, res, next) {
1816
}
1917

2018
res.status(200).json(result)
21-
console.log(
22-
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
23-
req
24-
)} to ${req.path} - ${JSON.stringify(req.query)}`
25-
)
26-
await Stats.findOneAndUpdate (
27-
{ _id: "systemstats" },
28-
{ $inc: { baka: 1 } },
29-
)
19+
20+
await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { baka: 1 } })
3021
} catch (error) {
31-
await Stats.findOneAndUpdate (
32-
{ _id: "systemstats" },
33-
{ $inc: { failed_requests: 1 } },
22+
await Stats.findOneAndUpdate(
23+
{ _id: 'systemstats' },
24+
{ $inc: { failed_requests: 1 } }
3425
)
3526
return next(error)
3627
}

src/controllers/gifs/randomBite.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const createError = require('http-errors')
2-
const requestIp = require('request-ip')
3-
const moment = require('moment')
42
const Bite = require('../../models/schemas/Bite')
53
const Stats = require('../../models/schemas/Stat')
64

@@ -18,19 +16,12 @@ module.exports = async function getRandomBite(req, res, next) {
1816
}
1917

2018
res.status(200).json(result)
21-
console.log(
22-
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
23-
req
24-
)} to ${req.path} - ${JSON.stringify(req.query)}`
25-
)
26-
await Stats.findOneAndUpdate (
27-
{ _id: "systemstats" },
28-
{ $inc: { bite: 1 } },
29-
)
19+
20+
await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bite: 1 } })
3021
} catch (error) {
31-
await Stats.findOneAndUpdate (
32-
{ _id: "systemstats" },
33-
{ $inc: { failed_requests: 1 } },
22+
await Stats.findOneAndUpdate(
23+
{ _id: 'systemstats' },
24+
{ $inc: { failed_requests: 1 } }
3425
)
3526
return next(error)
3627
}

src/controllers/gifs/randomBlush.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const createError = require('http-errors')
2-
const requestIp = require('request-ip')
3-
const moment = require('moment')
42
const Blush = require('../../models/schemas/Blush')
53
const Stats = require('../../models/schemas/Stat')
64

@@ -18,19 +16,12 @@ module.exports = async function getRandomBlush(req, res, next) {
1816
}
1917

2018
res.status(200).json(result)
21-
console.log(
22-
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
23-
req
24-
)} to ${req.path} - ${JSON.stringify(req.query)}`
25-
)
26-
await Stats.findOneAndUpdate (
27-
{ _id: "systemstats" },
28-
{ $inc: { blush: 1 } },
29-
)
19+
20+
await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { blush: 1 } })
3021
} catch (error) {
31-
await Stats.findOneAndUpdate (
32-
{ _id: "systemstats" },
33-
{ $inc: { failed_requests: 1 } },
22+
await Stats.findOneAndUpdate(
23+
{ _id: 'systemstats' },
24+
{ $inc: { failed_requests: 1 } }
3425
)
3526
return next(error)
3627
}

src/controllers/gifs/randomBonk.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const createError = require('http-errors')
2-
const requestIp = require('request-ip')
3-
const moment = require('moment')
42
const Bonk = require('../../models/schemas/Bonk')
53
const Stats = require('../../models/schemas/Stat')
64

@@ -18,19 +16,12 @@ module.exports = async function getRandomBonk(req, res, next) {
1816
}
1917

2018
res.status(200).json(result)
21-
console.log(
22-
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
23-
req
24-
)} to ${req.path} - ${JSON.stringify(req.query)}`
25-
)
26-
await Stats.findOneAndUpdate (
27-
{ _id: "systemstats" },
28-
{ $inc: { bonk: 1 } },
29-
)
19+
20+
await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bonk: 1 } })
3021
} catch (error) {
31-
await Stats.findOneAndUpdate (
32-
{ _id: "systemstats" },
33-
{ $inc: { failed_requests: 1 } },
22+
await Stats.findOneAndUpdate(
23+
{ _id: 'systemstats' },
24+
{ $inc: { failed_requests: 1 } }
3425
)
3526
return next(error)
3627
}

src/controllers/gifs/randomBored.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const createError = require('http-errors')
2-
const requestIp = require('request-ip')
3-
const moment = require('moment')
42
const Bored = require('../../models/schemas/Bored')
53
const Stats = require('../../models/schemas/Stat')
64

@@ -18,19 +16,12 @@ module.exports = async function getRandomBored(req, res, next) {
1816
}
1917

2018
res.status(200).json(result)
21-
console.log(
22-
`${req.method} | ${moment(Date.now()).format()} ${requestIp.getClientIp(
23-
req
24-
)} to ${req.path} - ${JSON.stringify(req.query)}`
25-
)
26-
await Stats.findOneAndUpdate (
27-
{ _id: "systemstats" },
28-
{ $inc: { bored: 1 } },
29-
)
19+
20+
await Stats.findOneAndUpdate({ _id: 'systemstats' }, { $inc: { bored: 1 } })
3021
} catch (error) {
31-
await Stats.findOneAndUpdate (
32-
{ _id: "systemstats" },
33-
{ $inc: { failed_requests: 1 } },
22+
await Stats.findOneAndUpdate(
23+
{ _id: 'systemstats' },
24+
{ $inc: { failed_requests: 1 } }
3425
)
3526
return next(error)
3627
}

0 commit comments

Comments
 (0)