Lab 6: NodeJS
Overview
In this lab, you will be working with NodeJS to create APIs interacting with postgres.
To receive credit for this lab, you MUST show your work to the TA during the lab, and push to the github by the deadline. Please note that submissions will be due right before your respective lab sessions in the following week. For Example, If your lab is on this Friday 10 AM, the submission deadline will be next Friday 10 AM. There is a "NO LATE SUBMISSIONS" policy for labs.
Learning Objectives
L01. Understand the basics of NodeJS for building web applicationsL02. Develop proficiency in using Postman for API testing
L03. Implement database queries with NodeJS and PostgreSQL
Part A
Pre-Lab Quiz
Complete this Pre-Lab quiz on Canvas before your section's lab.
Part B
Clone your GitHub repository
Github Classroom Assignment
- Using an SSH key
- Using a Personal Access Token (PAT)
git clone git@github.com:CU-CSCI3308-Fall2024/lab-6-nodejs-<YOUR_USER_NAME>.git
git clone https://github.com/CU-CSCI3308-Fall2024/lab-6-nodejs-<YOUR_USER_NAME>.git
Navigate to the repository on your system.
cd lab-6-nodejs-<YOUR_USER_NAME>
1. Directory structure
For this lab, your directory structure should be as follows:
|--init_data
|--create.sql
|--part_b_postman
|--index.js
|--lab-6-nodejs-postman-1.json
|--part_b_endpoints
|--index.js
|--lab-6-nodejs-postman-2.json
|--.gitignore
|--docker-compose.yaml
|--package.json
|--README.md
Find more information on package.json - here
2. Postman
Installation instructions for postman are here
Let's look at some useful features of Postman. The different buttons and tabs are numbered in the image below. You can find their usages and explanations below the image.
- New – This is where you will create a new request, collection or environment.
- Import – This is used to import a collection or environment. There are options such as import from file, folder, link or paste raw text.
- Runner – Automation tests can be executed through the Collection Runner. This will be discussed further in the next lesson.
- Open New – Open a new tab, Postman Window or Runner Window by clicking this button.
- My Workspace – You can create a new workspace individually or as a team.
- Invite – Collaborate on a workspace by inviting team members.
- History – Past requests that you have sent will be displayed in History. This makes it easy to track actions that you have done.
- Collections – Organize your test suite by creating collections. Each collection may have subfolders and multiple requests. A request or folder can also be duplicated as well.
- Request tab – This displays the title of the request you are working on. By default, “Untitled Request” would be displayed for requests without titles.
- HTTP Request – Clicking this would display a dropdown list of different requests such as GET, POST, COPY, DELETE, etc. In Postman API testing, the most commonly used requests are GET and POST.
- Request URL – Also known as an endpoint, this is where you will identify the link to where the API will communicate with.
- Save – If there are changes to a request, clicking save is a must so that new changes will not be lost or overwritten.
- Params – This is where you will write parameters needed for a request such as key values.
- Authorization – In order to access APIs, proper authorization is needed. It may be in the form of a username and password, bearer token, etc.
- Headers – You can set headers such as content type JSON depending on the needs of the organization.
- Body – This is where one can customize details in a request commonly used in POST request.
- Pre-request Script – These are scripts that will be executed before the request. Usually, pre-request scripts for the setting environment are used to ensure that tests will be run in the correct environment.
- Tests – These are scripts executed during the request. It is important to have tests as it sets up checkpoints to verify if response status is ok, retrieved data is as expected and other tests.
3. Writing API Routes
We can use HTTP Requests to send/retrieve data to/from our server.
HTTP Requests are made by a client (e.g. your web browser) in order to access some resource on the server. In order to do so, the client specifies:
- A URL (Uniform Resource Locator) -- For example: “/register”
- A series of HTTP headers
- Optionally, a request body
The server can accept this request and send a response, which may consist of a web page (HTML/CSS/JS), or a JSON object. You need to specify the nature of the content in the HTTP header of the response.
Reading User Input from the request
1. request.body
Generally used in POST/PUT requests. Use it when you want to send sensitive data(eg. form data) or lengthy JSON data to the server.
Example that works with request.body2. request.params
These are properties attached to the url i.e named route parameters. You prefix the parameter name with a colon(:) when writing your routes.
Example that works with request.params3. request.query
It is mostly used for searching, sorting, filtering, pagination, etc. Say for instance you want to query an API but only want to get data from page 10, this is what you'd generally use. It is appended to the request URL as <key> = <value>
.
Express
Express is a NodeJS framework that allows us to build web applications and APIs by defining HTTP routes and their callback functions(also called 'handler functions'). The application “listens” for requests that match the specified route(s) and method(s), and when it detects a match, it calls the specified callback function.
Following is an example of a basic route.
Querying the Database from a Node server
db.one()
When you expect the database query to return ONLY one row, you can use the db.one() method of the pg-promise library in Node. If the query returns more than one row, it will throw an error.
Example:
var query = `SELECT * FROM userInfo WHERE user_id = ${req.query.userid};`;
db.one(query)
.then(data => {
// data is representative of the result set of the query & it is expected to have
// ONLY 1 row
// do something
})
.catch(err => {
// throw error
});
db.any()
When you expect any number of rows to be returned for the query in execution, you can use db.any().
Example:
var query = `SELECT * FROM userInfo;`;
db.any(query)
.then(data => {
// data is representative of the result set of the query & it is expected to have
// ANY number of rows.
// do something
})
.catch(err => {
// throw error
});
db.task()
When you would like to execute multiple queries in the same operation, you can use db.task()
Example:
var username = req.query.username;
var city = req.query.city;
// Multiple queries using templated strings
var current_user = `select * from userinfo where username = '${username}';`;
var city_users = `select * from userinfo where city = '${city}';`;
// use task to execute multiple queries
db.task('get-everything', task => {
return task.batch([
task.any(current_user), //query 1
task.any(city_users), //query 2
]);
})
.then(data => {
//Here data is representative of the answer sets for each query.
//Each result set can contain any number of rows depending on the query conditions.
//more details on how to read the data object in such cases is included later in this writeup
})
.catch(err => {
// throw error;
});
4. Implementing endpoints and testing them using Postman
GET
A GET request will pass information to the server via the URL by appending parameters & values to the end of the URL address. This information can then be parsed and processed by the server.
Key Benefit: A get request is visible to the user and can therefore be bookmarked, saved, and shared by the user.
Example 1
Implementing a Default GET Endpoint :
const message = 'This is a default endpoint!';
app.get('/', (req, res) => {
res.send(message);
});
Testing the endpoint using POSTMAN
- Set your HTTP request to
GET
. - In the request URL field, input link.
- Click
Send
. - You will see
200 OK
status. - There should be
This is a default endpoint!
in the response body which indicates that your test has run successfully.
Testing the endpoint using a cURL command
To make an API call from the terminal we will be using cURL.
cURL stands for client URL. It is a command line tool that developers use to transfer data to and from a server. At the most fundamental level, cURL allows you to communicate with a server by specifying the location (in the form of a URL) and the data you want to send.
Following is a cURL command for the same use-case that we just worked out on Postman. You can get the curl command, from Postman, by clicking the </>
icon on the right panel.
curl --location --request GET 'http://localhost:3000/'
Example 2
How to execute multiple queries and parse the result :
In this example, the user is going to make a get request call to the endpoint getEmployee
with name
and city
as query parameters. We
have to implement the endpoint that fetches employee information based on name and city and send back the result to the user. The endpoint will eventually
fetch the required data from an employees
table.
request.query
Let us now see how to:
- Implement an endpoint to fetch user information.
- Execute multiple queries
- Collect and parse results from multiple queries.
We can also format our queries with data from the HTTP request using templated strings ( backtick(`) can be found just below ESC key). We have shown the usage of templated strings in the example below.
// <!-- Get Employee Details ("/getEmployee") -->
app.get('/getEmployee', function (req, res) {
// fetch query parameters from the request object
var name = req.query.name;
var city = req.query.city;
// multiple queries using templated strings
var employees_by_name = `select * from employees where name = '${name}';`;
var employees_by_city = `select * from employees where city = '${city}';`;
// use task to execute multiple queries
db.task('get-everything', task => {
return task.batch([
task.any(employees_by_name),
task.any(employees_by_city),
]);
})
// if query execution succeeds, query results can be obtained as shown below
.then(data => {
res.status(200).json({
employees_by_name: data[0],
employees_by_city: data[1],
});
})
// if the query execution fails, send the error message instead
.catch(error => {
console.error(
'Internal Server Error (HTTP 500): Oops! Something went wrong! Please check your code and try again.',
error
);
res.status('500').json({
employees_by_name: '',
employees_by_city: '',
error,
});
});
});
Testing this endpoint using Postman
- Set your HTTP request to
GET
. - In the request URL field, input link.
- You can use the
Params
tab below the request URL to add query parameters. Click onParams
, then enter the parameter name and value. - Click
Send
. - You will see
200 OK
status. - You should also be able to see the results of the query in the JSON response.
The result sets in the data
variable are in the same sequence in which the queries are executed. The format of the data
would be as follows:
data = [
[{}], // all the records from the employees table based on the query paramter "name". {} signifies 1 row with all the columns.
[{}], // all the records from the employees table based on the query paramter "city". {} signifies 1 row with all the columns.
];
For easier visualization, let's consider the employees
table in the database to be as follows:
employee_id | name | city |
---|---|---|
1 | John Doe | Boulder |
2 | Jane Smith | Boston |
3 | Michael Johnson | New York |
4 | Emily Brown | Boulder |
5 | David Lee | Boulder |
When we run a query, as in the example above, to return all rows from the employees
table, the data is converted into the json format for easier compatibility. The keys in the json objects are the names of the columns in the employees
table. Here is what the response for the employees
query would look like in the node server:
data[0] = [
{
employee_id: 1,
name: 'John Doe',
city: 'Boulder',
},
{
employee_id: 2,
name: 'Jane Smith',
city: 'Boston',
},
];
POST
A POST request will pass information to the server via a data package, which is hidden from the user. But be aware, this does not hide the information from anyone "sniffing" the network. You will have to use other tools (such as SSL) to properly secure the post request.
Key Benefit: Information is hidden from the user (& with SSL it can be secured), which makes this a great option for confidential information like login/registration data.
In this example, the user is going to make a post request call to the endpoint add_employee
with name
, email
, city
as body parameters. We have to implement the endpoint and also add a new entry to the table employees
based on the inputs.
request.body
// <!-- Add Employee ("/add_employee") -->
app.post('/add_employee', function (req, res) {
const query =
'insert into employees (name, email, city) values ($1, $2, $3) returning * ;';
db.any(query, [req.body.name, req.body.email, req.body.city])
// if query execution succeeds, send success message
.then(function (data) {
res.status(201).json({
status: 'success',
data: data,
message: 'data added successfully',
});
})
// if query execution fails, send error message instead
.catch(function (err) {
console.error(
'Internal Server Error (HTTP 500): Oops! Something went wrong! Please check your code and try again.',
error
);
res.status('500').json({
error,
});
});
});
Testing this endpoint using Postman
- Set your HTTP request to
POST
. - In the request URL field, input link
http://localhost:3000/add_employee
. - Under the
Body
tab -> selectRaw
radio button -> Then click on the dropdown and selectJSON
. - Add the JSON in the textbox as shown.
- Click on
Send
. - You will see
201 Created
status. - There should be
data added successfully
in the response which indicates that your insert has run successfully.
Testing the endpoint using a cURL command
The cURL command will look like:
curl --location 'http://localhost:3000/add_employee' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Mike Tyson",
"email": "miketyson@123.com",
"city": "New York"
}'
Take some time to figure out how to set up the PUT and DELETE routes in Postman by yourselves. Once you've got the hang of it, go ahead and utilize those skills in Part A of this lab. Check out Create and Send API Requests in Postman for your reference.
For the current and the upcoming labs, we recommend using Postman over cURL because it's way easier and more convenient to use.
5. Setting up your environment
Today we'll be using Docker Compose with a slightly modified configuration from lab 1.
In this lab, we will be using 2 containers, one for PostgreSQL and one for Node.js. If you need a refresher on the details of Docker Compose, please refer to lab 1.
1. In your repository, you will find a docker-compose.yaml file with the following contents:
version: '3.9'
services:
db:
image: postgres:14
env_file: .env
expose:
- '5432'
volumes:
- lab-6-nodejs:/var/lib/postgresql/data
- ./init_data:/docker-entrypoint-initdb.d
web:
image: node:lts
user: 'node'
working_dir: /home/node/app
environment:
- NODE_ENV=development
depends_on:
- db
ports:
- '3000:3000'
volumes:
- ./:/home/node/app
command: '#TODO ENTER THE COMMAND TO START YOUR SERVER'
# This defines our volume(s), which will persist throughout startups.
# If you want to get rid of a hanging volume, e.g. to test your database init,
# run `docker-compose rm -v`. Note that this will remove ALL of your data, so
# be extra sure you've made a stable backup somewhere.
volumes:
lab-6-nodejs:
2. Set up .env file
Create a .env file in the root (lab6-nodejs-<your_username>) folder to store environment variables to setup postgres.
# database credentials
POSTGRES_USER="postgres"
POSTGRES_PASSWORD="pwd"
POSTGRES_DB="hiking_db"
You should not commit this file to GitHub (it is in the .gitignore file, so this is automatic.)
3. Start the docker container with the docker-compose.yaml file:
docker-compose up -d
Nodemon
Nodemon is a tool that helps develop Node.js based applications by automatically restarting the node application when file changes in the directory are detected. nodemon does not require any additional changes to your code or method of development. nodemon is a replacement wrapper for node. To use nodemon, replace the word node on the command line when executing your script.
We have included nodemon in the package.json. The package.json file is a key part of any Node.js project and serves several important purposes. It contains metadata about the project, defines dependencies, and includes scripts for running various tasks.
"scripts": {
"start": "nodemon index.js"
}
If you are using a Windows/Linux OS and you see the following error:
nodemon: command not found
Then replace the "start" script in the package.json as shown below. Remember to replace <Github_Username> with your Username.
"scripts": {
"start": "./node_modules/nodemon/bin/nodemon.js lab6-nodejs-<Github_Username>"
}
If you find that nodemon is not able to detect your changes, add -L option to the the "start" script in the package.json as shown below.
"scripts": {
"start": "./node_modules/nodemon/bin/nodemon.js -L lab6-nodejs-<Github_Username>"
}
or
"scripts": {
"start": "nodemon -L index.js"
}
4. Shutting down containers
Now that we've learned how to start docker compose, let's cover how to shutdown the running containers. As long as you're still in the same directory, the command is as follows.
docker-compose down
5. Restarting Containers
For development purposes, it's often preferable to just restart the containers.
docker-compose up -d
And that's it!
Hiking Database
We've set up the tables shown below and you can find the SQL for it in the create.sql
file in the init_data
folder. You are not required to import that file into the db container. In the docker-compose.yaml
, we have already mapped the db
container's volume to the init_data
folder. When starting up, the db
container will read the create.sql
file and initialize the hiking database.
6. Part 1 - Write Postman calls to existing API routes
For this part, you will create a Postman collection containing all the routes that have been implemented in part_b_postman/index.js
, export the collection to a JSON and copy-paste its contents to the JSON file provided to you in the part_b_postman of the directory.
1. Start the PART 1 server
To initiate the server for Part 1, modify the command within the docker-compose.yaml file to
command: 'npm run start-server-part-b-postman'
Note that this server starts because nodemon executes the index.js file located in the part_b_postman
directory (Take a closer look at your package.json!).
2. Creating Postman Requests
Here are the steps you need to follow to create GET, POST, PUT and DELETE requests in Postman for the corresponding endpoint implementations in part_b_postman/index.js
:
Open Postman: Start by opening the Postman application.
Create a New Request: Click on the "New" button in the top-left corner of the Postman window and select "Request".
Enter Request Details: Give your request a name that describes what it does, like "GET Request for User Data".
Choose Request Method: Under the request name, you'll see a dropdown menu labeled "GET". This is where you choose the HTTP method for your request. For a GET request, you don't need to change anything, as it's already selected by default.
Enter Request URL: In the box next to the dropdown menu, enter the URL of the API endpoint you want to send the request to.
Send the Request: You can use the
Params
tab below the request URL to add query parameters to a GET Request. Click onParams
, then enter the parameter key and value. Once you've filled in all the necessary details, click the "Send" button to send the GET request.Repeat for POST, PUT, DELETE: To create requests for other HTTP methods, like POST, PUT and DELETE, follow the same steps as above, but make sure to select the appropriate method from the dropdown menu in step 4.
Add Request Body (for POST and PUT): For POST and PUT requests, you may need to include a request body with data. You can do this by clicking on the "Body" tab below the request URL and selecting the format (e.g., JSON) and entering the data you want to send.
Send the Request: Once you've filled in all the necessary details, click the "Send" button to send the request.
Check Response: After sending the request, you'll see the response from the server in the lower part of the Postman window. Make sure to check the response to ensure that your request was successful.
That's it!
3. Exporting the Postman Collection to JSON
Select Collection: In the sidebar on the left-hand side, click on the collection you want to export.
Click on the Three Dots: In the top-right corner of the Postman window, you'll see three dots (ellipsis) indicating more options. Click on these dots.
Choose "Export": From the dropdown menu that appears, select "Export".
Select Export Format: Postman allows you to export collections in various formats. Choose "Collection v2".
Save the File: After selecting the format as JSON, Postman will prompt you to save the exported collection file. Choose a location on your computer and save the file.
Review the implementations outlined in Part B.3 for the HTTP methods and grasp their structure in order to apply your expertise effectively in Part B.7.
7. Part 2 - Implementing API routes and testing from Postman
In this section, you will be
- Importing the json collection in the
part_b_endpoints
of your repo to your local Postman applications. - Implementing GET, PUT, POST, DELETE endpoints.
- Testing them using the imported Postman collection.
Importing a Postman collection (in JSON)
Go to Postman, and click on the
Import
button.Select the Postman collection file that is present in your repository (
lab-6-nodejs/part_b_endpoints/lab-6-nodejs-postman-2.json
). Note: It's okay if the screenshot doesn't look exactly the same because our file was in theDownloads
folder.You should now be able to see all the routes in your Postman
Implementing Endpoints
Before we begin, let us first take a look at the provided code skeleton in index.js in part_b_endpoints directory. The code is partitioned into 4 sections.
- Section 1 : Add all the dependencies needed to build your application
- Section 2 : Initialization (e.g Database connection)
- Section 3 : This is where you will add the implementation of all your TODO endpoints.
- Section 4 : Starting the server
// ************************************************
// <!-- Section 1 : Dependencies-->
// ************************************************
// importing the dependencies
// Express is a NodeJS framework that, among other features, allows us to create HTML templates.
const express = require('express');
const bodyParser = require('body-parser');
const pgp = require('pg-promise')();
require('dotenv').config();
// ************************************************
// <!-- Section 2 : Initialization-->
// ************************************************
// defining the Express app
const app = express();
// using bodyParser to parse JSON in the request body into JS objects
app.use(bodyParser.json());
// Database connection details
const dbConfig = {
host: 'db',
port: 5432,
database: process.env.POSTGRES_DB,
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
};
// Connect to database using the above details
const db = pgp(dbConfig);
// ************************************************
// <!-- Section 3 : TODOs Enpoint Implementation-->
// ************************************************
// <!-- Endpoint 1 : GET Endpoint Implementation (Default) -->
const message = 'Hey there!';
app.get('/', (req, res) => {
res.send(message);
});
// <!-- Endpoint 2 : GET Endpoint Implementation -->
app.get('/getTop3Trails', function (req, res) {});
// <!-- Endpoint 3 : POST Endpoint Implementation -->
app.post('/addReview', function (req, res) {});
// <!-- Endpoint 4 : PUT Endpoint Implementation -->
app.put('/updateReview', function (req, res) {});
// <!-- Endpoint 5 : DELETE Endpoint Implementation -->
app.delete('/deleteReview', function (req, res) {});
// <!-- Endpoint 6 : GET Endpoint Implementation -->
app.get('/getTrails', function (req, res) {});
// <!-- Endpoint 7 : GET Endpoint Implementation -->
app.get('/getReviewsByTrailID', function (req, res) {});
// ************************************************
// <!-- Section 4 : Start Server-->
// ************************************************
// starting the server and keeping the connection open to listen for more requests
app.listen(3000, () => {
console.log('listening on port 3000');
});
Start server
To initiate the server for Part B, modify the command within the docker-compose.yaml file to
command: 'npm run start-server-part-b-endpoints'
Note that this server starts because nodemon executes the index.js file located in the part_b_endpoints
directory (Take a closer look at your package.json).
Start Docker Desktop and run your docker-compose.yaml file using docker compose up -d
command. This should have your server running in the background. The web and db containers should be running.
Please make sure you are familiar with the hiking database before you start implementing the endpoints.
You can refer to the create.sql
for the inputs for while calling the endpoint.
Endpoint 1 is the default endpoint. You don't need to implement it.
Make sure you don't modify any of the route paths in the provided routes as they will be used for testing.
1. GET
Modify the GET
API route function handler to return the top 3 trails in california based on rating and a 200
status code.
2. POST
Modify the POST
API route function handler to add a new review. From the hiking_db schema, You can notice that we have separate tables for reviews
and images
and these are linked using mapping table i.e. reviews_to_images
.
- The user should have the flexibilty of adding review with or without image details. Therefore your endpoint should be capable of handling both the scenarios.
- If the user provides image details along with review details, make sure you add an entry to
reviews
table,images
table and also add mapping information to thereviews_to_images
. - For executing multiple queries, you can use db.task(). You can also refer to endpoint 2(Get User Details ("/getUserInfo")) defined in index.js in
part_b_postman
directory. - The route should return
Data added successfully
message,review_id
andimage_id
(If image details are provided by the user) and a201
status code to the client after the review has been added to the database. - Make sure save the response as we will using the review_id and image_id in next steps.
3. PUT
Modify the PUT
API route function handler to allow a user to update a review they posted.
- The user should be able to change the text or update an image. When processing the request, the route should check if the user is sending new data for the text or a new image, or both, and accordingly update the appropriate tables.
- The user will be sending the
review_id
andimage_id
(You can use the review_id and image_id obtained from the previous POST request) when making thisPUT
request. - The route should return
Data updated successfully
message and a201
status code to the client after the review has been updated in the database.
You can refer this to learn if-else and Null check in javascript
4. DELETE
Modify the DELETE
API route function handler to allow an admin to delete a review. You can delete the review based on review_id
or username
or rating
. The route should return a Data deleted successfully
message and a 200
status code to the client after the review has been deleted from the database. Make sure that the corresponding entry from the reviews_to_images
is also deleted.
Testing the Endpoints using Postman
Now that you have access to all the routes from the imported Postman collection in your local Postman application, you can navigate through each route and send a request for each one to verify that the request is successful and that your endpoint has been properly implemented.
Part C
5. GET (Retrieve data on filters)
Modify the GET
API route function handler to allow users to search for different trails based on filters - difficulty and location. The request may contain any or both filters. The request may look as follows:
{
difficulty: 1,
location: null
}
OR
{
difficulty: 1;
}
You need to parse the difficulty and convert it into strings - "easy"
, "moderate"
, "difficult"
, "very_difficult"
.
For example, difficulty = 1
needs to be converted into "easy"
, difficulty = 2
needs to be converted into "moderate"
, and so on.
You can use either if-else statements or switch-case to accomplish the same.
6. GET (Retrieve data for an id)
Modify the GET
API route function handler to show reviews for a selected trail based on trail_id
.
In the part_b_endpoints
directory, we have provided you a postman collection named lab-6-nodejs-postman-2.json
. Once you modify all the route function handlers, import the collection
in postman and ensure that the API responses match the expected responses.
Submission Guidelines
Commit and upload your changes
- For Part B-1 (Postman), you need to update the lab-6-nodejs-postman-1.json file in the
part_b_postman
directory with the contents of your exported Postman JSON collection. - For Part B-2 (Endpoints), you need to update the index.js file in the
part_b_endpoints
directory with the endpoint implementations and test them against the provided Postman JSON collection.
git add .
git commit -m "Update part_b_postman collection and part_b_endpoints index.js files"
git push
Once you have run the commands given above, please navigate to your GitHub remote repository (on the browser) and check if the changes have been reflected.
You will be graded on the files that were present before the deadline. If the files are missing/not updated, you could receive a grade as low as 0. This will not be replaced as any new pushes to the repository after the deadline will be considered as a late submission and we do not accept late submissions.
Regrade Requests
Please use this link to raise a regrade request if you think you didn't receive a correct grade. If you received a lower than expected grade because of missing/not updated files, please do not submit a regrade request as they will not be considered for reevaluation.
Rubric
Description | Points | |
---|---|---|
PART A: Pre-Lab Quiz | Complete the Pre-Lab Quiz before your lab | 20 |
PART B (Postman): GET (Default) | Postman request for the GET (Default) is present in the exported JSON collection | 5 |
PART B (Postman): GET | Postman request for the GET (/getUserInfo) is present in the exported JSON collection | 5 |
PART B (Postman): POST | Postman request for the POST (/add_user) is present in the exported JSON collection | 6 |
PART B (Postman): PUT | Postman request for the PUT (/update_user) is present in the exported JSON collection | 5 |
PART B (Postman): DELETE | Postman request for the DELETE (/delete_user/:username) is present in the exported JSON collection | 5 |
PART B (Endpoints): GET | Requests to the GET endpoint to return the top 3 trails in california based on rating succeed | 6 |
PART B (Endpoints): POST | Requests to the POST endpoint to add a new review succeed | 6 |
PART B (Endpoints): PUT | Requests to the PUT endpoint to update a review succeed | 6 |
PART B (Endpoints): DELETE | Requests to the DELETE endpoint to delete a review succeed | 6 |
PART C (Endpoints): GET #1 | The user should be able search for trail based on filters | 5 |
PART C (Endpoints): GET #2 | The user should be able to view reviews for a specific trail | 5 |
In-class check-in | You showed your progress to a course staff | 20 |
Total Score | 100 |
Please refer to the individual sections for information on file names and content to be included in them.