mirror of
https://codeberg.org/tacerus/teddit.git
synced 2024-11-22 06:49:26 +01:00
Allow disabling Redis usage, for debugging and single user instances
This commit is contained in:
parent
2c447f967f
commit
0a2cca3ee4
34
app.js
34
app.js
@ -11,20 +11,32 @@ const express = require('express')
|
||||
const cookieParser = require('cookie-parser')
|
||||
const r = require('redis')
|
||||
|
||||
const redisOptions = {
|
||||
host: '127.0.0.1',
|
||||
port: 6379
|
||||
}
|
||||
|
||||
if (config.redis_host) {
|
||||
redisOptions.host = config.redis_host
|
||||
}
|
||||
const redis = (() => {
|
||||
if (!config.redis_enabled) {
|
||||
// Stub Redis if disabled
|
||||
return {
|
||||
get: (_, callback) => callback(null, null),
|
||||
setex: (_, _1, _2, callback) => callback(null),
|
||||
on: () => {}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.redis_port && config.redis_port > 0) {
|
||||
redisOptions.port = config.redis_port
|
||||
}
|
||||
const redisOptions = {
|
||||
host: '127.0.0.1',
|
||||
port: 6379
|
||||
}
|
||||
|
||||
if (config.redis_host) {
|
||||
redisOptions.host = config.redis_host
|
||||
}
|
||||
|
||||
if (config.redis_port && config.redis_port > 0) {
|
||||
redisOptions.port = config.redis_port
|
||||
}
|
||||
|
||||
const redis = r.createClient(redisOptions)
|
||||
return r.createClient(redisOptions)
|
||||
})()
|
||||
const helmet = require('helmet')
|
||||
const bodyParser = require('body-parser')
|
||||
const fetch = require('node-fetch')
|
||||
|
@ -3,6 +3,7 @@ const config = {
|
||||
reddit_app_id: 'H6-HjZ5pUPjaFQ', // You should obtain your own Reddit app ID. For testing purposes it's okay to use this project's default app ID. Create your Reddit app here: https://old.reddit.com/prefs/apps/. Make sure to create an "installed app" type of app.
|
||||
cert_dir: '', // For example '/home/teddit/letsencrypt/live/teddit.net', if you are using https. No trailing slash.
|
||||
video_enabled: true,
|
||||
redis_enabled: true, // If disabled, does not cache Reddit API calls
|
||||
redis_host: '127.0.0.1',
|
||||
redis_port: 6379,
|
||||
ssl_port: 8088,
|
||||
|
Loading…
Reference in New Issue
Block a user