From de2ddfd66ab807a4ad78c19f67e0a5c237a8cea0 Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Thu, 13 Feb 2020 02:40:01 +0900 Subject: [PATCH] Enable console log for cache in production --- pages/api/comments.js | 6 ++---- pages/api/discourse.js | 6 ++---- pages/api/github.js | 4 +--- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/pages/api/comments.js b/pages/api/comments.js index 1b131e8655..a3676be024 100644 --- a/pages/api/comments.js +++ b/pages/api/comments.js @@ -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 @@ -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}`) 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 { diff --git a/pages/api/discourse.js b/pages/api/discourse.js index ba5463c69a..fc7036ddfa 100644 --- a/pages/api/discourse.js +++ b/pages/api/discourse.js @@ -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 { diff --git a/pages/api/github.js b/pages/api/github.js index 1a7165b0fe..dfea754d07 100644 --- a/pages/api/github.js +++ b/pages/api/github.js @@ -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 {