Skip to content
 
 

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Database Interacation in Web Applications

This demonstrates the cconnection of MySQL database and Node.js to create a simple API

Requirements

Setup

  1. Clone the repository

  2. Initialize the node.js environment

    npm init -y
    
  3. Install the necessary dependancies

    npm install express mysql2 dotenv nodemon
    
  4. Create a server.js and .env files

  5. Basic server.js setup

    const express = require('express')
    const app = express()
    
    
    // Question 1 goes here
    
    
    // Question 2 goes here
    
    
    // Question 3 goes here
    
    
    // Question 4 goes here
    
    
    
    // listen to the server
    const PORT = 3000
    app.listen(PORT, () => {
      console.log(`server is runnig on http://localhost:${PORT}`)
    })



Run the server

nodemon server.js



Setup the .env file

DB_USERNAME=root
DB_HOST=localhost
DB_PASSWORD=your_password
DB_NAME=hospital_db



Configure the database connection and test the connection

Configure the server.js file to access the credentials in the .env to use them in the database connection


1. Retrieve all patients

Create a GET endpoint that retrieves all patients and displays their:

  • patient_id
  • first_name
  • last_name
  • date_of_birth

2. Retrieve all providers

Create a GET endpoint that displays all providers with their:

  • first_name
  • last_name
  • provider_specialty

3. Filter patients by First Name

Create a GET endpoint that retrieves all patients by their first name


4. Retrieve all providers by their specialty

Create a GET endpoint that retrieves all providers by their specialty


NOTE: Do not fork this repository

About

plp-database-design-aug-week-5-assignment-db_week5 created by GitHub Classroom

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages