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'; | |
export default class Input extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
value: '' | |
}; | |
this.handleChange = this.handleChange.bind(this); | |
this.handleKeyPress = this.handleKeyPress.bind(this); |
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'; | |
export default class List extends Component { | |
renderItem(text, i) { | |
const { onClickItem } = this.props; | |
return ( | |
<div onClick={() => onClickItem(i)}>{text}</div> | |
); | |
}; |
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'; | |
import { connect } from 'react-redux'; | |
import { actionCreators } from './actions'; | |
import Input from './Input'; | |
import List from './List'; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = {}; |
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 { types } from './actions'; | |
const initialState = { | |
todos: ['Plan web app', 'Analyze use of app', 'Design and develop app', 'Test app', 'Implement and maintain app'] | |
}; | |
export const reducer = (state = initialState, action) => { | |
const { todos } = state; | |
const { type, payload } = action; |
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 |
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
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
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
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 mongoose = require('mongoose'); | |
const Schema = mongoose.Schema; | |
module.exports = mongoose.model('User', new Schema({ | |
name: String, | |
password: String, | |
admin: Boolean | |
})); |
NewerOlder