代写 2019/4/18 osu-cs493-sp19/assignment-1-gushengjun: assignment-1-gushengjun created by GitHub Classroom

2019/4/18 osu-cs493-sp19/assignment-1-gushengjun: assignment-1-gushengjun created by GitHub Classroom
osu-cs493-sp19 / assignment-1-gushengjun assignment-1-gushengjun created by GitHub Classroom
Private
1 commit 1 branch 0 releases 1 contributor
Branch: master
New pull request
Create new file
Upload files
Find File
Clone or download
robwhess Add complete assignment description. Latest commit a0ff5eb 20 days ago
.gitignore Add complete assignment description. 20 days ago
README.md Add complete assignment description. 20 days ago
README.md
Assignment 1
Assignment due at 11:59pm on Monday 4/22/2019
Demo due by 11:59pm on Monday 5/6/2019
The goals of this assignment are to have you practice designing a RESTful API from an application description, to begin implementing endpoints for the API you designed, and to containerize your API using Docker. The assignment has a few different parts, which are outlined below.
0. Sign up for Piazza
Use this link to sign up for CS 493 on Piazza using your ONID email address:
https://piazza.com/oregonstate/spring2019/cs493
We’ll be using Piazza in this course for Q&A because it’s geared towards students helping other students with the class. Anyone can post or answer a question on Piazza, even anonymously, and the instructor and TAs can revise and endorse student answers, which means you can be confident in the quality of the response.
You are strongly encouraged to post any class-related questions to Piazza first instead of emailing the instructor or TAs. You should also get in the habit of checking in to Piazza to answer other students’ questions. This will not only enable everyone to get help quickly, but it will also help you improve your understanding of the material, since teaching someone else is the best way to learn something.
As an incentive to use Piazza, extra credit will be awarded to the most active Piazza participants at the end of the class.
1. Design a RESTful API for a Yelp-like application
Your first task for this assignment is to design a RESTful API (i.e. API endpoints with corresponding request and response bodies) for a Yelp-like application. This application will specifically be centered around businesses and user reviews of businesses in US cities. The API you design should permit the following functionality:
Users who own businesses should be able to add their businesses to the application. When a business owner adds their business they will need to include the following information:
Business name
Business street address Business city
Business state
Business ZIP code Business phone number
Business category and subcategories. We’ll talk more about categories and subcategories just below, but these will need to match a list of pre-defined categories and subcategories set up by the administrators of the application.
https://github.com/osu-cs493-sp19/assignment-1-gushengjun 1/3

2019/4/18 osu-cs493-sp19/assignment-1-gushengjun: assignment-1-gushengjun created by GitHub Classroom
https://github.com/osu-cs493-sp19/assignment-1-gushengjun 2/3
The following information may also optionally be included when a new business is added:
Business website Business email
Business owners may modify any of the information listed above for an already-existing business they own. Business owners may remove a business from the application.
Users may get a list of businesses. The representations of businesses in the returned list should include all of the information described above. In a later assignment, we will implement functionality to allow the user to list only a subset of the businesses based on some filtering criteria, but for now, assume that users will only want to fetch a list of all businesses.
Users may fetch detailed information about a business. Detailed business information will include all of the information described above as well as reviews of the business and photos of the business (which we discuss below).
Users may write a review of an existing business. A review will include the following information:
A “star” rating between 0 and 5 (e.g. 4 stars)
An “dollar sign” rating between 1 and 4, indicating how expensive the business is (e.g. 2 dollar signs) An optional written review
Note that a user may write at most one review of any business.
Users may modify or delete any review they’ve written.
Users may upload image files containing photos of an existing business. Each photo may have an associated caption. Users may remove any photo they’ve uploaded, and they may modify the caption of any photo they’ve uploaded. Users may list all of the businesses they own.
Users may list all of the reviews they’ve written.
Users may list all of the photos they’ve uploaded.
Your design should follow the best practices we discuss in lecture, such as URL naming, etc. As you’re designing your API, make sure to think about which API responses should be paginated, which API responses should include links to other API resources (i.e. how your API will implement HATEOAS), and what API endpoints will need some form of authentication. For now, you should make note of all this, but you don’t need to worry about it when implementing the server for this assignment.
There is no formal deliverable for this part of the assignment, but it will be useful to go through the exercise of designing your API before implementing it.
2. Implement a server for your API
After you’ve designed your API, implement a server for it using Node.js and Express. Your server should meet the following requirements:
A route should be included to implement each of the API endpoints in your design.
Any API endpoint with a parameterized route should perform basic verification of the specified route parameters.
Any API endpoint that takes a request body should perform basic verification of the data provided in the request body. Each API endpoint should respond with an appropriate HTTP status code and, when needed, a response body.
API endpoints should have paginated responses where appropriate.
Your server should run on the TCP port specified by the PORT environment variable.
You should be able to launch your server using the command npm start .

2019/4/18 osu-cs493-sp19/assignment-1-gushengjun: assignment-1-gushengjun created by GitHub Classroom
https://github.com/osu-cs493-sp19/assignment-1-gushengjun 3/3
Importantly, DO NOT worry about actually storing API data in your server. When a client makes a request to your API that includes a request body (e.g. a business), you may simply validate the body without storing it. When a client makes a request to your API that would generate a response body, you can simply send back (hard-coded) dummy data with the appropriate format.
There is no formal testing requirement for this assignment, but be prepared to send appropriate queries (using cURL, Postman, etc.) to demonstrate the complete functionality of your API during your grading demo for the assignment.
3. Containerize your server using Docker
Your last task for this assignment is to write a Dockerfile that packages the API server you wrote into a Docker image along with all of the server’s runtime dependencies. Containers launched from this image should automatically start the server listening on a specified port, and you should be able to successfully make requests to the containerized server from the outside world (e.g. from your host machine).
Submission
We’ll be using GitHub Classroom for this assignment, and you will submit your assignment via GitHub. Just make sure your completed files are committed and pushed by the assignment’s deadline to the master branch of the GitHub repo that was created for you by GitHub Classroom. A good way to check whether your files are safely submitted is to look at the master branch your assignment repo on the github.com website (i.e. https://github.com/osu-cs493-sp19/assignment-1- YourGitHubUsername/). If your changes show up there, you can consider your files submitted.
Grading criteria
This assignment is worth 100 total points, broken down as follows: 20 points: Signed up for Piazza
70 points: Implemented API server
35 points: API server implements a route to allow each piece of functionality described above
10 points: API design reflects best practices for a RESTful API, as discussed in class (e.g. URL naming, etc.) 10 points: API endpoints perform basic verification of route parameters and request bodies
10 points: API endpoints respond with appropriate HTTP status codes and response bodies
5 points: API endpoints send paginated responses when appropriate
10 points: API server is containerized using Docker