Assignment 04-07
Cloud and Web Services with Database Integration
The following outlines a series of assignments designed to build proficiency in developing
RESTful APIs, integrating them with various database solutions, and understanding cloud-
based database deployment using AWS.
Assignment Roadmap
I. Foundational JavaScript and JSON Skills
This assignment focuses on essential JavaScript concepts and JSON manipulation, which are
crucial prerequisites for building robust web services. These assignments will solidify your
understanding of data handling in JavaScript.
• Objective: Develop core JavaScript programming skills, particularly for array, string,
file, and JSON manipulation.
• Assignments:
1. Array Manipulation: Write a JavaScript function that takes an array of integers
as input and returns a new array with each element multiplied by 2.
2. String Handling: Write a JavaScript program that takes a string input from the
user and checks if it is a palindrome or not.
3. File Operations (Node.js fs Module):
▪ Write a JavaScript function that reads a text file and logs its content to
the console using the fs module in Node.js.
▪ Write a JavaScript function that reads a JSON file using the fs module
in Node.js, parses the content into a JavaScript object, modifies the
object, and then writes the updated object back to the file.
4. JSON Manipulation:
▪ Parsing JSON: Write a JavaScript function that takes a JSON string as
input and parses it into a JavaScript object. Implement error handling
using try/catch blocks for potential parsing errors.
▪ Stringifying JSON: Write a JavaScript function that takes a JavaScript
object as input and converts it into a JSON string.
II. Building a RESTful API with In-Memory Data Store
This assignment introduces the fundamental concepts of RESTful API development using
Node.js and Express.js, starting with a simple in-memory data store.
• Objective: Create a basic RESTful API to manage a collection of books, storing data
temporarily in a JavaScript array.
• Requirements:
1. Setup:
▪ Install Node.js and npm (Node Package Manager).
▪ Initialize a new Node.js project and install Express.js.
2. Data Structure: Each book should have an id, title, and author.
3. In-memory Data Store: Use a JavaScript array to store the books. It is
important to note that each time the server is restarted, the data will reset.
4. API Endpoints (for Books): Implement the following standard RESTful
endpoints:
▪ GET /books: Returns a list of all books.
▪ GET /books/:id: Returns a specific book by ID.
▪ POST /books: Adds a new book to the collection.
▪ PUT /books/:id: Updates a specific book by ID.
▪ DELETE /books/:id: Deletes a specific book by ID.
5. Testing: Use a tool like Postman to test your API endpoints.
III. Building a RESTful API with MongoDB Data Store
Building on the previous assignment, this part integrates a persistent NoSQL database,
MongoDB, for data storage, addressing the limitations of in-memory data.
• Objective: Create a RESTful API to manage a collection of movies, ensuring data
persistence using MongoDB.
• Requirements:
1. Setup:
▪ Install Node.js, npm, MongoDB, and the MongoDB driver for
Node.js.
▪ Initialize a new Node.js project and install Express.js and the
MongoDB driver.
2. Data Structure: Each movie should have an id, title, director, and year.
3. MongoDB Data Store: Use MongoDB to store the movies. A key advantage
here is that each time the server is restarted, the data will persist.
4. API Endpoints (for Movies): Implement the following RESTful endpoints for
managing movies:
▪ GET /movies: Returns a list of all movies.
▪ GET /movies/:id: Returns a specific movie by ID.
▪ POST /movies: Adds a new movie to the collection.
▪ PUT /movies/:id: Updates a specific movie by ID.
▪ DELETE /movies/:id: Deletes a specific movie by ID.
5. Testing: Use a tool like Postman to test your API endpoints.
IV. Deploying Databases with AWS RDS
This advanced assignment focuses on deploying and integrating relational databases using
Amazon Web Services (AWS) Relational Database Service (RDS) and EC2 instances.
• Objective: Explore, deploy, and integrate a relational database using AWS RDS with
an EC2 instance.
• Assignments:
1. Explore RDS: Explore RDS and introduce yourself with the basic
functioning of RDS.
2. Account Configuration: Mention all the steps used for your AWS account’s
configuration.
3. Local Database Creation: Create a database in MySQL (or any other
Query language) in your local machine. This involves understanding SQL
concepts.
4. Deploy to RDS: Deploy your locally created database using RDS.
5. EC2 Integration: Create an EC2 instance and integrate it with RDS.
6. Documentation: Mention all the steps used and paste the screenshots of
your account’s configuration in a single word file and upload it. This
ensures proper documentation of your cloud setup.
V. Additional JavaScript Application Practice
The following questions focuses on general JavaScript application development.
1. Bill Splitter Application: Write a bill splitter Application using JavaScript where the input
is the bill amount and number of people, and the output is the bill per person.
2. Student Attendance Webpage: Create a webpage and write a JavaScript program to show
student attendance results on a weekly basis for a subject.
a. The total number of classes in a week is 7.
b. The document should contain a form with radio buttons for a teacher to select
absence or presence for 10 students.
c. The page also allows selecting the date and time for attendance marking.
d. On submitting attendance, it should prompt a message for successful entry.
e. The program should display:
i. List of student names with their attendance percentage.
ii. Count of students with attendance <=80%, <=70%, <=60%, <=50%.
3. NZM Special Train Reservation System: Create a webpage and write a JavaScript
program for a reservation system for the NZM special train.
a. Assume 5 different routes, each with ten different trains, and each train has a
capacity of eight seats.
b. The document should contain a form with radio buttons for route selection and a
drop-down box for train selection.
c. The page allows selecting the date and time for reservation.
d. The customer name should consist of only letters or blank spaces, generating an
alert if incorrect.
e. Use regular expressions to validate:
i. Email in the format aa@bb.cc where aa, bb, and cc are one or more
alphanumeric characters.
ii. Optional telephone field in the pattern ddd-ddd-dddd or ddd-dddd where d
is any digit.
f. On reservation, prompt a message for successful entry or unavailability.
g. The program should display:
i. Total number of reservations by the system.
ii. Reservations per train.
iii. Reservations per route.
References
Concept Resource Link
JavaScript
https://www.w3schools.com/js/js_array_methods.asp
Array Methods
Palindrome
https://www.programiz.com/javascript/examples/palindrome
String Check
Node.js File
https://accuweb.cloud/resource/articles/how-to-work-with-files-using-the-
Operations (fs
fs-module-in-node-js
module)
JSON Parsing
https://www.w3resource.com/javascript-exercises/error-handling/javascript-
& Error
error-handling-exercise-13.php
Handling
RESTful API
https://dev.to/anticoder03/building-restful-apis-with-nodejs-and-express-
with Node.js
step-by-step-tutorial-2oc6
and Express
CRUD in
https://www.scaler.com/topics/expressjs-tutorial/crud-in-express-js/
Express.js
AWS RDS and
EC2 https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Welcome.html
Documentation