Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions pages/api/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import { BLOG_URL, FORUM_URL } from '../../src/consts'

const cache = new NodeCache({ stdTTL: 900 })

const dev = process.env.NODE_ENV === 'development'

const cors = Cors({
allowedMethods: ['GET', 'HEAD'],
origin: BLOG_URL
Expand All @@ -36,13 +34,13 @@ const getCommentCount = async (req, res) => {
}

if (cache.get(url) !== undefined) {
if (dev) console.log(`Using cache for ${url}`)
console.log(`Using cache for ${url}`)
Comment on lines -39 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.debug()?


res.status(200).json({ count: cache.get(url) })

return
} else {
if (dev) console.log(`Not using cache for ${url}`)
console.log(`Not using cache for ${url}`)
}

try {
Expand Down
6 changes: 2 additions & 4 deletions pages/api/discourse.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ import { FORUM_URL } from '../../src/consts'

const cache = new NodeCache({ stdTTL: 900 })

const dev = process.env.NODE_ENV === 'development'

export default async (_, res) => {
if (cache.get('topics')) {
if (dev) console.log('Using cache for "topics"')
console.log('Using cache for "topics"')

res.status(200).json(cache.get('topics'))

return
} else {
if (dev) console.log('Not using cache for "topics"')
console.log('Not using cache for "topics"')
}

try {
Expand Down
4 changes: 1 addition & 3 deletions pages/api/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import NodeCache from 'node-cache'

const cache = new NodeCache({ stdTTL: 900 })

const dev = process.env.NODE_ENV === 'development'

export default async (_, res) => {
if (!process.env.GITHUB_TOKEN) {
res.status(200).json({ issues: [] })
} else {
if (cache.get('issues')) {
if (dev) console.log('Using cache for "issues"')
console.log('Using cache for "issues"')

res.status(200).json({ issues: cache.get('issues') })
} else {
Expand Down