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
49 changes: 49 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// const express = require('express');
// const app = express();
// const port = 3000;

// app.get('/', (req, res) => {
// res.send('Hello World!')
// })

// app.listen(port, () => {
// console.log(`Example app listening at http://localhost:${port}`)
// })

// app.get("/customers", async (req, res) => {
// let customerData = await getCustomerData();
// res.send(customerData);
// })

// async function getCustomerData(){

var mysql = require('mysql');

let con = mysql.createConnection({
host: "localhost",
user: "root",
password: 'password',
database: "classicmodels"
});

con.connect(function(err) {
if(err) throw err;
console.log("Connected")
});

// let data = await new Promise((resolve, reject) => {
// con.query("SELECT * FROM customers", (err, result, fields) => {
// if(err){
// reject(err)
// }
// else {
// resolve(result)
// }
// })
// })

con.end();

return data;

//}
3 changes: 3 additions & 0 deletions data/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
USE classicmodels;

SELECT * FROM customers;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need the sql used to create your pokemon database here

38 changes: 29 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
const express = require('express')
const app = express()
const port = 3000
// // const express = require('express')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You moved all the backend logic to rest/index.js so you can delete this file

// // const app = express()
// // const port = 3000
// let mysql = require('mysql');
// let password = "password";

// // app.get('/', (req, res) => {
// // res.send('Hello World!')
// // })

// // app.listen(port, () => {
// // console.log(`Example app listening at http://localhost:${port}`)
// // })

// let con = mysql = mysql.createConnection({
// host: "localhost",
// user: "root",
// password: password,
// database: "classicmodels"
// });


// con.query("SELECT * FROM customers", (err, result, fields) => {
// if(err){
// throw err;
// }
// console.log(result)
// con.end();
// });

app.get('/', (req, res) => {
res.send('Hello World!')
})

app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
31 changes: 31 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// let mysql = require("mysql");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this file if it only contains commented out code


// let con = mysql = mysql.createConnection({
// host: "localhost",
// user: "root",
// password: password,
// database: "classicmodels"
// });

// con.connector(err => {
// if(err){
// throw err;
// }
// con.query("SELECT * FROM customers", (err, result, fields) => {
// if(err){
// throw err;
// }
// console.log(result)
// })
// });

// const Sequelize = require('sequelize');
// let sequelize = new Sequelize('mysql://root:${password}@:port/dbname-sample');

// let Users = sequelize.define('users', {
// name: Sequelize.STRING,
// age: Sequelize.INTEGER,
// username: Sequelize.STRING
// });

// Users.findAll().then(console.log)
Loading