This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ul = document.getElementById('users'); | |
const url = 'https://jsonplaceholder.typicode.com'; | |
// Create the type of element you pass in the parameters | |
function createNode(element) { | |
return document.createElement(element); | |
} | |
// Append the second parameter(element) to the first one | |
function append(parent, el) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
todos: [], | |
todo: '', | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import App from './App'; | |
import React from 'react'; | |
import { configure, shallow } from 'enzyme'; | |
import Adapter from 'enzyme-adapter-react-16'; | |
configure({ adapter: new Adapter() }); | |
describe('App', () => { | |
it('should have the `th` "Todos"', () => { | |
const wrapper = shallow( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Sample Data | |
----------- | |
movie | |
------------------------------------------------ | |
id title yr director budget gross | |
actor | |
----------- | |
id name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const Schema = mongoose.Schema; | |
module.exports = mongoose.model('User', new Schema({ | |
name: String, | |
password: String, | |
admin: Boolean | |
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
'secret': 'thisissupposedtobetopsecret', | |
'database': 'mongodb://localhost:27017/test' | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const bodyParser = require('body-parser'); | |
const morgan = require('morgan'); | |
const mongoose = require('mongoose'); | |
const jwt = require('jsonwebtoken'); | |
const config = require('./config'); | |
const User = require('./app/models/user'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MongoClient = require('mongodb').MongoClient; | |
const url = 'mongodb://localhost:27017/test'; | |
mongoClient.connect(url, function(err, db) { | |
if (err) { | |
throw err; | |
console.log('ERROR - Unable to connect to database.') | |
} | |
console.log('INFO - Database connected.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render } from 'react-dom'; | |
import { createStore } from 'redux'; | |
import App from './App'; | |
import { reducer } from './reducer'; | |
const store = createStore(reducer); | |
render(<App store={store}/>, document.getElementById('root')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const types = { | |
ADDTODO: 'ADD_TODO', | |
REMOVETODO: 'REMOVE_TODO' | |
}; | |
export const actionCreators = { | |
addTodo: item => { | |
return { | |
type: types.ADDTODO, | |
payload: item |
OlderNewer