Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api setup #3

Open
wants to merge 3 commits into
base: serverbuild
Choose a base branch
from
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
46 changes: 0 additions & 46 deletions dataMigration/app.js

This file was deleted.

46 changes: 46 additions & 0 deletions dataMigration/postgresql.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// const { Pool, Client } = require('pg')
// const Pass = require('../env/config.js');

// /* These files have been deleted to save space */
// // const Questions = require('./questions.csv');
// // const Answers = require('./answers.csv');
// // const A_Photos = require('./answers_photos.csv');

// const pool = new Pool({
// user: 'postgres',
// host: 'localhost',
// database: 'atelier',
// password: Pass.PASS,
// port: 5432,
// });
// pool.connect();

// pool.query('CREATE TABLE questions(q_id SERIAL, question_id numerical, a_body VARCHAR(500), date timestamp, username VARCHAR(25), user_email VARCHAR(25), reported integer, helpful_count integer, PRIMARY KEY(q_id)', (err, res) => {
// console.log(err, res);
// }).then(res => {
// pool.query("COPY questions(q_id, question_id, a_body, date, username, user_email, reported, helpful_count) FROM Answers DELIMITER ',' CSV HEADER;", (err, res) => {
// console.log(err, res)
// }).then(res => {
// pool.query("alter table questions alter column date type date using to_timestamp(date / 1000)::date;");
// console.log(err, res);
// })
// }).catch(err => console.log(err));

// pool.query('CREATE TABLE answers(a_id SERIAL, product_id numerical, q_body VARCHAR(500), date timestamp, username VARCHAR(25), user_email VARCHAR(25), reported integer, helpful_count integer, PRIMARY KEY(a_id)', (err, res) => {
// console.log(err, res);
// }).then(res => {
// pool.query("COPY answers(a_id, product_id, q_body, date, username, user_email, reported, helpful_count) FROM Answers DELIMITER ',' CSV HEADER;", (err, res) => {
// console.log(err, res)
// }).then(res => {
// pool.query("alter table answers alter column date type date using to_timestamp(date / 1000)::date;");
// console.log(err, res);
// })
// }).catch(err => console.log(err));

// pool.query('CREATE TABLE answers_photos(p_id SERIAL, answers_id numerical, url varchar(200) PRIMARY KEY(p_id)', (err, res) => {
// console.log(err, res);
// }).then(res => {
// pool.query("COPY answers(a_id, answers_id, url) FROM A_Photos DELIMITER ',' CSV HEADER;", (err, res) => {
// console.log(err, res)
// })
// }).catch(err => console.log(err));
141 changes: 141 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
"axios": "^0.27.2",
"cloudinary-core": "^2.13.0",
"cloudinary-react": "^1.8.1",
"cors": "^2.8.5",
"date-fns": "^2.29.2",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"morgan": "^1.10.0",
"nodemon": "^2.0.19",
"pg": "^8.8.0",
"react": "^18.2.0",
Expand Down
1 change: 0 additions & 1 deletion server/db-mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pool.connect();
module.exports = {

getQs: (req) => {
console.log("models.getQs works");
// pool.query("SELECT json_agg(q) FROM q", (err, res) => {
// console.log(err, res);
// })
Expand Down
10 changes: 10 additions & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@ require("dotenv").config();
const express = require("express");
const app = express();
const path = require("path");
const router = require("./routes");

// var morgan = require('morgan');
// var cors = require('cors');

// app.use(morgan('dev'));
// app.use(cors());

app.use(express.json());
app.use(express.static(path.join(__dirname, "../client/dist")));

//set up routes
app.use(router);

const PORT = process.env.PORT || 3000;

app.listen(PORT);
Expand Down