Skip to content

Instantly share code, notes, and snippets.

View laere's full-sized avatar
🎯
Focusing

Zack laere

🎯
Focusing
  • Grand Rapids, MI
View GitHub Profile
const Joi = require("joi");
const registerValidationSchema = Joi.object().keys({
name: Joi.string()
.min(2)
.max(30)
.required(),
email: Joi.string()
.email()
.required(),
router.post("/register", (req, res) => {
const userProps = req.body;
const { email } = userProps;
User.findOne({ email })
.then(user => {
if (user) {
return res.status(400).json({ errormessage: "User already exists." });
} else {
const avatar = gravatar.url(email, {
import React from 'react';
import { addBudget } from 'actions';
import { connect } from 'react-redux';
import BudgetForm 'components/Budgets/BudgetForm';
class BudgetCreate extends React.Component {
onSubmit = formValues => {
this.props.addBudget(formValues);
}
@laere
laere / Budget.js
Last active February 15, 2019 22:23
const mongoose = require('mongoose');
const { Schema } = mongoose;
const TransactionSchema = require('./Transaction');
const budgetSchema = new Schema({
title: String,
description: String,
amount: { type: Number, default: 0 },
startDate: Date,
endDate: Date,
@laere
laere / FetchActionCreators.js
Created March 14, 2016 18:28 — forked from l0gicgate/FetchActionCreators.js
Reusable action creators / reducers.
import axios from 'axios';
class FetchActionCreators {
constructor(endpoint, actions) {
const [REQUEST, SUCCESS, FAILURE] = actions;
this.actions = {
REQUEST,
SUCCESS,
FAILURE,
///Click func
handleOnClick(e) {
e.preventDefault();
//save input value
let inputValue = this.refs.inputfield.value;
if(inputValue === '') return;
//pass input value to callback
this.props.addTodo(inputValue)
}
// Dependencies
var express = require('express');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
// Define our Todo Model
var Todo = mongoose.model('Todo', {
text: String
});
import dotProp from 'dot-prop-immutable';
//save string values to vars
const ADD_TODO = 'ADD_TODO';
let nextId = 0;
//the action is whats performed to alter state
//addItem is an action creator and nees to return an action
export const AddTodo = (text) => {
return {
type: ADD_TODO,
import React, { Component } from 'react';
import ListItem from '../components/ListItem';
export default class List extends Component {
// renderTodos() {
// return this.props.items.map((item) => {
// return (
// <Listitem key={item.id}>
// {item.text}
filterMovies: function() {
var moviePosters = [];
for (var i; i <= 5; i++) {
if(apiData.rating >= 8) {
return moviePosters.push(apiData.Poster[i]);
} else {
return;
}
}
},