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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitingore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
IGNOREME
Empty file added IGNOREME
Empty file.
22 changes: 22 additions & 0 deletions build/webpack-bundle.js

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions client/components/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import PropTypes from 'prop-types';
import fetch from 'isomorphic-fetch';
import React, { Component } from 'react';

class App extends Component {
constructor(props){
super(props)
this.state = {}
console.log('constructor working')
}

render(){
console.log('render working')
const thingToDispay = 'this fucking thing'
return (
<div> {thingToDispay} </div>
)
}
}
export default App
11 changes: 11 additions & 0 deletions client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import { render } from 'react-dom';
import App from './components/App';

// uncomment so that webpack can bundle styles
//import styles from './scss/application.scss';

render(
<App />,
document.getElementById('root')
);
Empty file added client/scss/application.scss
Empty file.
109 changes: 109 additions & 0 deletions controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
const Sequelize = require('sequelize');

const sequelize = new Sequelize('itemsList', 'famesStore', 'Seth', {
host: 'localhost',
dialect: 'postgres'
});

const Item = sequelize.define('item', {
itemId: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
sellerId: Sequelize.INTEGER,
sellerRating: Sequelize.INTEGER,
category: Sequelize.STRING,
itemName: Sequelize.STRING,
price: Sequelize.INTEGER,
condition: Sequelize.STRING,
quantity: Sequelize.INTEGER,
});

const User = sequelize.define('user', {
userId: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
userName: Sequelize.STRING,
password: Sequelize.STRING,
sellerRating: Sequelize.INTEGER,
itemsBought: Sequelize.STRING,
itemsToSell: Sequelize.STRING,
description: Sequelize.STRING,
});

//User.hasMany(Item, {foreignKey: "itemId"});
//Item.hasOne(User, {foreignKey: "userId"});

sequelize.sync({force: true});

let dbController = {

createUser: (req, res, next) => {
console.log(req.body)
User
.build({
userName: req.body.userName,
password: req.body.userPassword,
description: req.body.userDescription,
})
.save()
//.then(anotherTask => {
// you can now access the currently saved task with the variable anotherTask... nice!
//})
.catch(error => {
console.log(error)
})
next();
},

createItem: (req, res, next) => {
console.log(req.body)
Item
.build({
category: req.body.itemCategory,
itemName: req.body.itemName,
price: req.body.itemPrice,
condition: req.body.itemCondition,
quantity: req.body.itemQuantity,
description: req.body.itemDescription
})
.save()
//.then(anotherTask => {
// you can now access the currently saved task with the variable anotherTask... nice!
//})
.catch(error => {
console.log(error)
})
next();
},

getAllItems: (req, res) => {
console.log("in the GEETTTT", req.body)
//let items = Item.findAll({})
// , (err, data) => {
//console.log("ITEMSSS", Item.findAll({}));
sequelize.query('SELECT * FROM items').then(function(data) {

//res.locals = data[0];
res.send(data[0]);
});

//next()
// console.log("DATAAAAA", data);
// if(err) return res.status(404).send(err);
//res.send(Item.findAll({}));
// });
}

}

module.exports = dbController;
// what does the sync method do?
// const itemRecord = Item.build('item');
// await itemRecord.save();
// const userRecord = User.build('user');
// await userRecord.save();
// });
// });







57 changes: 57 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<html>
<head>
<meta charset="UTF-8">
<title>Fame's Store</title>
<!-- comment out the below link tags when bundling styles with webpack -->
<!-- <link rel="stylesheet" href="client/stylesheets/styles.css"> -->
<style>
body {
background-color: powderblue;
}
h1 {
color: blue;
}
form {
margin: 0 auto;
width: 350px;
padding: 1em;
border: 5px solid #CCC;
border-radius: 1em;
}
label {
display: inline-block;
padding: 1em;
width: 100px;
}
</style>
</head>
<body>
<h1><center>Fame's Store</center></h1>
<div id="root">
<form method="POST" action="/addUser">
<label>CREATE USER</label><br>
<div>
<label for="name">NAME:</label>
<input type="text" name="userName">
</div>
<div>
<label for="description">DESCRIPTION:</label>
<input type="text" name="userDescription">
</div>
<div>
<label for="password">PASSWORD:</label>
<input type="text" name="userPassword">
</div>
<input type="submit" value="ADD USER">
</form>
</div>


<!-- bundle for gulp build -->
<!-- <script src="build/bundle.js"></script> -->

<!-- uncomment below and comment out the tag above for webpack challenge -->
<!--<script src="build/webpack-bundle.js"></script>-->

</body>
</html>
19 changes: 19 additions & 0 deletions indexREACT.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<html>
<head>
<meta charset="UTF-8">
<title>Fame's Store</title>
<!-- comment out the below link tags when bundling styles with webpack -->
<!-- <link rel="stylesheet" href="client/stylesheets/styles.css"> -->
</head>
<body>
<h1>Fame's Store</h1>
<div id="root"></div>

<!-- bundle for gulp build -->
<!-- <script src="build/bundle.js"></script> -->

<!-- uncomment below and comment out the tag above for webpack challenge -->
<script src="build/webpack-bundle.js"></script>

</body>
</html>
69 changes: 69 additions & 0 deletions items.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<html>
<head>
<meta charset="UTF-8">
<title>Fame's Store</title>
<!-- comment out the below link tags when bundling styles with webpack -->
<!-- <link rel="stylesheet" href="client/stylesheets/styles.css"> -->
<style>
body {
background-color: powderblue;
}
h1 {
color: blue;
}
form {
margin: 0 auto;
width: 350px;
padding: 1em;
border: 5px solid #CCC;
border-radius: 1em;
}
label {
display: inline-block;
padding: 1em;
width: 100px;
}
</style>
</head>
<body>
<h1><center>Fame's Store</center></h1>
<div id="root">
<form method="POST" action="/addItem">
<label>SELL ITEM</label><br>
<div>
<label for="name">NAME:</label>
<input type="text" name="itemName">
</div>
<div>
<label for="description">DESCRIPTION:</label>
<input type="text" name="itemDescription">
</div>
<div>
<label for="price">PRICE:</label>
<input type="text" name="itemPrice">
</div>
<div>
<label for="category">CATEGORY:</label>
<input type="text" name="itemCategory">
</div>
<div>
<label for="quantity">QUANTITY:</label>
<input type="text" name="itemQuantity">
</div>
<div>
<label for="condition">CONDITION:</label>
<input type="text" name="itemCondition">
</div>
<input type="submit" value="ADD ITEM">
</form>
</div>


<!-- bundle for gulp build -->
<!-- <script src="build/bundle.js"></script> -->

<!-- uncomment below and comment out the tag above for webpack challenge -->
<!--<script src="build/webpack-bundle.js"></script>-->

</body>
</html>
21 changes: 21 additions & 0 deletions items.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
DROP DATABASE IF EXISTS items;
CREATE DATABASE items;

\c items;

CREATE TABLE goods (
ID SERIAL PRIMARY KEY,
seller VARCHAR,
seller_rating INTEGER,
category VARCHAR,
item_name VARCHAR,
price INTEGER,
condition VARCHAR,
description VARCHAR,
quantity INTEGER,
comments VARCHAR,
likes INTEGER
);

INSERT INTO goods (seller, seller_rating, category, item_name, price, condition, description, quantity, comments, likes)
VALUES ('Eric', 5, 'Tech', 'Macbook', 1000, 'new', 'Great new Macbook', 3, 'This is a great product', 4);
1 change: 1 addition & 0 deletions newFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("HELLO")
41 changes: 41 additions & 0 deletions node-postgres-promises/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var createError = require('http-errors');
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);
app.use('/users', usersRouter);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
next(createError(404));
});

// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};

// render the error page
res.status(err.status || 500);
res.render('error');
});

module.exports = app;
Loading