Skip to content

cyberfocused/SimpleREST_API2

Repository files navigation

Step #1 -once I have set up all of the folders in Visual Studio Code, I open a new terminal window

and type npm initialize (node package manger- this creates the "package.json" file)

image

Step #2 -in the terminal window I type "npm install express"

then "Set-ExecutionPolicy unresticted"

image

Step #3 - the app on line 3 I have entered into code will handle the API requests

image

Step #4 - Here I am testing the API code I have so far

image

Step #5 - I tested to see that the http mesage loads in a browser:

image

Step #6 -I added app.get, app.post, app.put, and app.delete in my code and then tested each function in Postman:

image

Step #7 -testing the Get function in Postman:

image

Step #8 -testing the Post function in Postman:

image

Step #9 -testing the Put function in Postman:

image

Step #10 -testing the Delete function in Postman:

image

Step #11 -I added two new patients and records for each of them:

image

Step #12 -When I send the request to the API, I want to be able to

validate the person to make sure they exist ( that their SSN# matches

and that the appropriate record is returned. The header of the

HTTP request is used to send the authentication data

image

Step #13 -I request the medical records in the body:

image

... the medical records request printed in the Terminal:

image

Step #14 -I request the medical records in the body:

image

Step #15 -I entered code for VS Code to generate a "Status Code 404 error#

if the wrong SSN# is entered:

image

... I enter an INVALID SSN# in Postman to test:

image

... Postman generates Status Code- '404 Not Found :

image

Step #16 -Code created in Visual Studio that will generate errors if

if the first and lat names are correct but ssn# is incorrectly entered:

image

... error "401 Unauthorized is generated "first/Last name didn't match SSN":

image

Step #17 - if the patient requests his records they will dislay:

image

... error "501 will display if the records are improperly requested":

image

Step #18 - creating a new patient in Postman:

image

... code for the new patient and it prints in the terminal:

image

Step #19 - Using the Put method: I update existing Patient phone number:

image

... error - Patient not found:

image

About

A Simple REST API that I built

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages