Skip to content
Open
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
2 changes: 1 addition & 1 deletion client/src/containers/with_static_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const withStaticContext = withProps(({
staticContext: { data: staticData = {}, host = '' } = {}
}) => {
const isClient = () => typeof window !== 'undefined';
const clientData = isClient ? (window as any).__staticContext?.data : {};
const clientData = isClient() ? (window as any).__staticContext?.data : {};

const data = !isEmpty(staticData) ? staticData : clientData;

Expand Down
42 changes: 21 additions & 21 deletions lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ import {
PAPERTRAIL_PORT,
} from './config';

const winstonConsole = new winston.transports.Console({
format: winston.format.combine(
winston.format.prettyPrint({ colorize: true })
),
level: 'silly',
});

const transports = [ winstonConsole ];

if (NODE_ENV === 'production') {
const winstonPapertrail: any = new PapertrailTransport({
host: PAPERTRAIL_HOST,
hostname: ENV_NAME,
level: PAPERTRAIL_LEVEL,
port: PAPERTRAIL_PORT,
});

transports.push(winstonPapertrail);
}

export default winston.createLogger({ transports });
// const winstonConsole = new winston.transports.Console({
// format: winston.format.combine(
// winston.format.prettyPrint({ colorize: true })
// ),
// level: 'silly',
// });
//
// const transports = [ winstonConsole ];
//
// if (NODE_ENV === 'production') {
// const winstonPapertrail: any = new PapertrailTransport({
// host: PAPERTRAIL_HOST,
// hostname: ENV_NAME,
// level: PAPERTRAIL_LEVEL,
// port: PAPERTRAIL_PORT,
// });
//
// transports.push(winstonPapertrail);
// }
//
// export default winston.createLogger({ transports });
20 changes: 10 additions & 10 deletions lib/mail.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import mailgun from 'mailgun-js';

import { MAILGUN_DOMAIN, MAILGUN_FROM, MAILGUN_KEY, NODE_ENV } from 'lib/config';
import log from 'lib/logger';
// import log from 'lib/logger';

export default function sendMail({ to, subject, text }) {
log.info('sendMail attempt', { to, subject, text });
// log.info('sendMail attempt', { to, subject, text });
if (NODE_ENV !== 'development' && MAILGUN_KEY) {
const mailer = mailgun({ apiKey: MAILGUN_KEY, domain: MAILGUN_DOMAIN });
// const mailer = mailgun({ apiKey: MAILGUN_KEY, domain: MAILGUN_DOMAIN });

const email = {
from: MAILGUN_FROM,
subject,
text,
to,
};
// const email = {
// from: MAILGUN_FROM,
// subject,
// text,
// to,
// };

mailer.messages().send(email, (err, res) => log.info('sendMail', err, res));
// mailer.messages().send(email, (err, res) => log.info('sendMail', err, res));
}
}
4 changes: 2 additions & 2 deletions lib/notify.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash'

import sendMail from 'lib/mail'
import log from 'lib/logger'
// import log from 'lib/logger'

const actionNotifier = ({ resource, action, identifier, meta }) => {
let description = `${_.capitalize(resource)} ${action}: ${identifier}`
Expand All @@ -10,7 +10,7 @@ const actionNotifier = ({ resource, action, identifier, meta }) => {
const text = `${description}` + (meta ? `\n${JSON.stringify(meta)}` : '')
const subject = `[commits.to] ${description}`

log.info('actionNotifier', { to, subject, text })
// log.info('actionNotifier', { to, subject, text })
return sendMail({ to, subject, text })
}

Expand Down
8 changes: 4 additions & 4 deletions lib/parse/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import momenttz from 'moment-timezone'
import Sherlock from 'sherlockjs'
import _ from 'lodash'

import log from '../../lib/logger'
// import log from '../../lib/logger'

export const dateOr = ({ date, or = undefined }) =>
date && date !== '' && moment(date).toDate() || or;

export const parseTimezone = (ip) => {
log.info('parseTimezone', ip)
// log.info('parseTimezone', ip)
return new Promise((resolve) => {
ipapi.location((response) => {
const failures = ['Undefined', 'None', null]
const timezone = _.includes(failures, response) ? undefined : response
log.info('ipapi response:', response, !!timezone && timezone)
// log.info('ipapi response:', response, !!timezone && timezone)
resolve(timezone) // fix ipapi
}, ip, '', 'timezone')
})
Expand All @@ -38,7 +38,7 @@ export const parseSherlock = ({ text, timezone }) => {
Sherlock._setNow(theDate)
const result = Sherlock.parse(text)

log.debug('parseSherlock', timezone, currentOffset, theDate, text)
// log.debug('parseSherlock', timezone, currentOffset, theDate, text)
return result
}

Expand Down
2 changes: 1 addition & 1 deletion models/pledge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Pledge {
public static find = ({ id: rawId, username: rawUsername, urtext }: IPledge = {}) => {
const { id, username } = PledgeParser.parse({ id: rawId, username: rawUsername, urtext });

return Promises.find({
return Promises.findOne({
include: [User.includeModelFor({ username })],
where: { id },
});
Expand Down
Loading