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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": [
["env", { "modules": false }],
"stage-3"
]
}
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# package directories
node_modules
jspm_packages

# Serverless directories
.serverless
8 changes: 8 additions & 0 deletions backend/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"table": "movies",
"host": "jrdevleague.cb9co1xxtizk.us-west-2.rds.amazonaws.com",
"database": "whs_alex",
"user": "agent_8",
"password": "woomy",
"port": 5432
}
46 changes: 46 additions & 0 deletions backend/routes/delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict' //do not know what this does
const Pool = require('pg-pool'); //get PG pool for pool
const config = require('../config.json');

const { //gets variables from config.json
table,
host,
database,
user,
password,
port
} = config;

const pool = new Pool({ //makes a new Postgres instance
host,
database,
user,
password,
port,
idleTimeoutMillis: 1000
});

module.exports.deleteMovie = (event, context, callback) => {
let {value} = event.body;
const deleteSomeMovie = `DELETE FROM ${movies} WHERE name= $1 ;`; //commands postgres to get data from table

pool.connect()
.then(client => {
client.release();
return client.query(deleteSomeMovie,[value]);
})
.then(data => {
const response = {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true
},
body: JSON.stringify({
message: data,
input: event,
}),
};
callback(null, response);
});
};
45 changes: 45 additions & 0 deletions backend/routes/get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict' //do not know what this does
const Pool = require('pg-pool'); //get PG pool for pool
const config = require('../config.json');

const { //gets variables from config.json
table,
host,
database,
user,
password,
port
} = config;

const pool = new Pool({ //makes a new Postgres instance
host,
database,
user,
password,
port,
idleTimeoutMillis: 1000
});

module.exports.getMovie = (event, context, callback) => {
const getAllMovies = `SELECT * FROM ${table}`; //commands postgres to get data from table

pool.connect()
.then(client => {
client.release();
return client.query(getAllMovies);
})
.then(data => {
const response = {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true
},
body: JSON.stringify({
message: data,
input: event,
}),
};
callback(null, response);
});
};
46 changes: 46 additions & 0 deletions backend/routes/post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict' //do not know what this does
const Pool = require('pg-pool'); //get PG pool for pool
const config = require('../config.json');

const { //gets variables from config.json
table,
host,
database,
user,
password,
port
} = config;

const pool = new Pool({ //makes a new Postgres instance
host,
database,
user,
password,
port,
idleTimeoutMillis: 1000
});

module.exports.postMovie = (event, context, callback) => {
let {name, genre, release_date, rating} = event.body;
const postSomeMovie = `INSERT INTO ${table} VALUES(DEFAULT,$1,$2,$3,$4);`; //commands postgres to get data from table

pool.connect()
.then(client => {
client.release();
return client.query(postSomeMovie,[name,genre,release_date,rating]);
})
.then(data => {
const response = {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true
},
body: JSON.stringify({
message: data,
input: event,
}),
};
callback(null, response);
});
};
60 changes: 60 additions & 0 deletions backend/routes/put.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict' //do not know what this does
const Pool = require('pg-pool'); //get PG pool for pool
const config = require('../config.json');

const { //gets variables from config.json
table,
host,
database,
user,
password,
port
} = config;

const pool = new Pool({ //makes a new Postgres instance
host,
database,
user,
password,
port,
idleTimeoutMillis: 1000
});

module.exports.putMovie = (event, context, callback) => {
let {oldMovie,newMovie} = event.body;
const putSomeMovie = `UPDATE ${movies} SET Somevalue = $1 WHERE Somevalue = $2;`; //commands postgres to get data from table

pool.connect()
.then(client => {
client.release();
return client.query(putSomeMovie,[oldMovie,newMovie]);
})
.then(data => {
const response = {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Credentials': true
},
body: JSON.stringify({
message: data,
input: event,
}),
};


callback(null, response);
});
};

/*
{
"table": "movies",
"host": "jrdevleague.cb9co1xxtizk.us-west-2.rds.amazonaws.com",
"database": "whs_tim_kunta_kinte_jameson",
"user": "jrdevleague",
"password": "jrD3vLeague!",
"port": 5432
}
YOU FUCKIN SUCK !!!
*/
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>movie_project</title>
</head>
<body>
<div id="app"></div>
<script src="/dist/build.js"></script>
</body>
</html>
Loading