Skip to content

Instantly share code, notes, and snippets.

login(req, res) {
const { username, shaHash } = req.body;
res.setHeader('Content-Type', 'application/json');
User.findOne({ username, verified: true }, (err, user) => {
if (!user) {
console.log('No user with that username found or not verified');
res.status(500);
res.end();
return;
export function sendJobAlertEmail() {
console.log('CRON: sending alert email');
function handleJobs(jobs, user, notifiableJobs, done) {
each(jobs, (job, n) => {
Notification.count({ jobId: job._id, userId: user._id }, (err, count) => {
if (count > 0) {
console.log('notificaiton already sent');
return n();
}
{
"_id",
"name"
}
import React from 'react';
import { connect } from 'react-redux';
/**
* A higher order function that returns a function whose argument is the component
* to be wrapped.
*
* usage example:
* const EnsureLoggedIn = AuthWrapper();
* <EnsureLoggedIn(Profile) />
@sungwoncho
sungwoncho / README.md
Last active January 5, 2016 10:49
Coddee test example

Coddee test example

An example code from coddee. These are a set of tests written using mocha and chai.

In webhook_method_tests.js, I am testing that the method saves a MongoDB document into a collection.

In webhook_tests.js, I am testing that this method is called when a webhook comes in from GitHub.

I wrote two different tests because the middleware that detects the GitHub webhook is an event emitter, and I don't have much control over how long it takes to actually save a document to a collection.