Skip to content

Cu 86b2myahg extract db connection karla sanchez - #13

Open
karlasanc wants to merge 4 commits into
devfrom
CU-86b2myahg_Extract-DB-Connection_Karla-Sanchez
Open

Cu 86b2myahg extract db connection karla sanchez#13
karlasanc wants to merge 4 commits into
devfrom
CU-86b2myahg_Extract-DB-Connection_Karla-Sanchez

Conversation

@karlasanc

@karlasanc karlasanc commented Nov 4, 2024

Copy link
Copy Markdown
Contributor

Extracted database connection code from index.js to db.js.

  • updated mysql library to mysql2
  • created .env.example file for developers to rename and update with their credentials
  • created the boulders database in mysql to store data locally
  • removed database logic from index.js and relocated it to the auth.js route

To Test:

Connect to MySQL Database Locally

  • Install MySQL locally
  • Start MySQL directly from your terminal:
    mysql.server start

Create your MySQL database

  • Open a new terminal window and login to mysql
    mysql -u root -p
  • Create the new database
    CREATE DATABASE boulders;
  • Verify your database was created
    SHOW DATABASES;

Run Knex Migrations and Seed Data

  • Using an editor of your choice (ex. VS Code) open your project file and navigate to the backend folder (P1/backend).
  • Rename the ".env.example" file to ".env".
  • Open the ".env" file and edit line 7 and 8 to correspond with your database credentials
Screenshot 2024-11-03 at 11 13 54 PM
  • Navigate to the P1/backend from within the terminal
    cd P1/backend
  • Re-install dependencies in your terminal
    npm install
  • Install Database and Seed Data through your terminal
    npm run migrate
    npm run seed

Start Node Application & Test Connection

  • Start Application
    npm start
  • Navigate to the Home Page on the Browser
    http://localhost:3000/api/auth/users
Screenshot 2024-11-03 at 11 19 01 PM

@netlify

netlify Bot commented Nov 4, 2024

Copy link
Copy Markdown

Deploy Preview for team-boulders-notflix failed.

Name Link
🔨 Latest commit 88d8b60
🔍 Latest deploy log https://app.netlify.com/sites/team-boulders-notflix/deploys/67284b1eed70940008461b52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant