Improve environment variable stuff

This commit is contained in:
Jonathan Cremin 2015-08-30 18:35:05 +02:00
parent 760ee07a2e
commit 6ba174cff0
16 changed files with 66 additions and 64 deletions

View file

@ -10,7 +10,7 @@ const debug = debugname('hostr-api');
const router = new Router();
const statsdOpts = {prefix: 'hostr-api', host: process.env.STATSD_HOST || 'localhost'};
const statsdOpts = {prefix: 'hostr-api', host: process.env.STATSD_HOST};
router.use(stats(statsdOpts));
const statsd = new StatsD(statsdOpts);
router.use(function* statsMiddleware(next) {

View file

@ -13,11 +13,11 @@ import { formatFile } from '../../lib/format';
import debugname from 'debug';
const debug = debugname('hostr-api:file');
const redisUrl = process.env.REDIS_URL || process.env.REDISTOGO_URL || 'redis://localhost:6379';
const redisUrl = process.env.REDIS_URL;
const fileHost = process.env.FILE_HOST || 'http://localhost:4040';
const baseURL = process.env.WEB_BASE_URL;
const storePath = process.env.STORE_PATH || path.join(process.env.HOME, '.hostr', 'uploads');
const storePath = process.env.UPLOAD_STORAGE_PATH;
export function* post(next) {
if (!this.request.is('multipart/*')) {
@ -60,7 +60,7 @@ export function* post(next) {
const fileId = yield hostrId(Files);
// Fire an event to let the frontend map the GUID it sent to the real ID. Allows immediate linking to the file
const acceptedEvent = `{"type": "file-accepted", "data": {"id": "${fileId}", "guid": "${tempGuid}", "href": "${fileHost}/${fileId}"}}`;
const acceptedEvent = `{"type": "file-accepted", "data": {"id": "${fileId}", "guid": "${tempGuid}", "href": "${baseURL}/${fileId}"}}`;
this.redis.publish('/user/' + this.user.id, acceptedEvent);
this.statsd.incr('file.upload.accepted', 1);
@ -173,7 +173,7 @@ export function* post(next) {
this.status = 201;
this.body = formattedFile;
if (process.env.VIRUSTOTAL) {
if (process.env.VIRUSTOTAL_KEY) {
// Check in the background
process.nextTick(function* malwareScan() {
debug('Malware Scan');

View file

@ -6,7 +6,7 @@ import passwords from 'passwords';
import debugname from 'debug';
const debug = debugname('hostr-api:user');
const redisUrl = process.env.REDIS_URL || process.env.REDISTOGO_URL || 'redis://localhost:6379';
const redisUrl = process.env.REDIS_URL;
export function* get() {
this.body = this.user;