Giter Club home page Giter Club logo

cs3219-taskb's Introduction

CS3219 Task B

Student Information

Name: Kor Ming Soon Matriculation Number: A0201975A Github Repo: https://github.com/kormingsoon/cs3219-taskb

Credit: https://medium.com/@dinyangetoh/how-to-build-simple-restful-api-with-nodejs-expressjsand-mongodb-99348012925d

I have only completed Task B1 and Task B4.

Note that in the section, I am segmenting Task B1 and Task B4 separately. The sections are as follows:


Task B4

In task B4, I have implemented the react front end. The styling can be found in style.css and bootstrap has been comporated.

  1. Demonstration of API calls with front end.

    1.1 POST & GET

    1.2 PUT: upon clicking the edit button, a pop up window will appear allowing the user to edit the old inputs. Observe that the ID remains the same.
    1.3 DELETE : upon clicking the delete button. The contact list is now empty.

Task B1

  • Local Deployment
  • Hosted Deployment
  • Error-Resiliency Testing

Local Deployment

In this segment we will run and observe the GET, POST, PUT and DELETE API calls on a locally deployed web application using postman. In this example, we will use contacts, containing the name and email, as the model for our api calls.

  1. Ensure that node.js is installed in your computer.

  2. Run the app with the following command

     npm start
    
  3. After running the application, go to the following site and observe that the app is running on express.

     localhost:8080
    

    localhost:8080

  4. You can visit the following links to observe the routing. In /contacts, the data you observe may be different.

     localhost:8080/goto
     localhost:8080/goto/contacts
    
  5. Now, we will use postman to carry out the API calls.

    5.1 For the GET API request. We can simply see that the requests returns the list of contacts in the database. Right now, there are two contact details. We access: localhost:8080/goto/contacts:


    5.2 For the POST API request. For the post request, we will be adding in name: Sahil is the best and email: [email protected]. You can then observe that the contact is newly created. You can return back to localhost:8080/goto/contacts to see all of the contacts.


    5.3 For the DELETE API request. For the delete request, we will delete the first contact, which has the id 61372278808b3deec9fde3df. We will key in localhost:8080/goto/contacts/61372278808b3deec9fde3df with a DELETE request.

    The above contains the contact with the id that we will delete

    The above illustrates the delete api through postman.

    The above illustrates the difference in the contact list after deletion.

    5.4 For the PUT API request. We will edit the contact we added earlier (Sahil is the best) to a different name Prof Bimlesh is the best, along with the email. Notice that the id remains the same.

Hosted Deployment

  1. Similar to above, we will illustrate the API calls using the deployed endpoints instead of our localhost. The website is hosted on the link: https://cs3219-ay2122-task-b.herokuapp.com/. We will test the API calls on https://cs3219-ay2122-task-b.herokuapp.com/goto/contacts.

    1.1 For the GET API request. We can simply see that the requests returns the list of contacts in the database. Right now, there are two contact details. We access: localhost:8080/goto/contacts:


    1.2 For the POST API request. For the post request, we will be adding in name: Hosting is the best and email: [email protected]. You can then observe that the contact is newly created. You can return back to https://cs3219-ay2122-task-b.herokuapp.com/goto/contacts to see all of the contacts.


    1.3 For the DELETE API request. For the delete request, we will delete the first contact, which has the id 613729e6a70e493233e8a942. We will key in https://cs3219-ay2122-task-b.herokuapp.com/goto/contacts/613729e6a70e493233e8a942 with a DELETE request.

    The above contains the contact with the id that we will delete

    The above illustrates the delete api through postman.

    The above illustrates the difference in the contact list after deletion.

    1.4 For the PUT API request. We will edit the contact we added earlier (Hosting is the best) to a different name Local deployment is the best, along with the email. Notice that the id remains the same.

Error-Resiliency Testing

In the error-resiliency testing, we will be testing the error resiliency with the hosted domain.

Again, the domain is https://cs3219-ay2122-task-b.herokuapp.com/

a. Test Case 1:

https://cs3219-ay2122-task-b.herokuapp.com/999999999

b. Test Case 2:

https://cs3219-ay2122-task-b.herokuapp.com/goto/123r15fdsafdsa

c. Test Case 3:

https://cs3219-ay2122-task-b.herokuapp.com/goto/contacts/123456

d. Test Case 4:

https://cs3219-ay2122-task-b.herokuapp.com/goto/contacts/613736c191b3b15deed7b1be

  1. Test Case 5:

https://cs3219-ay2122-task-b.herokuapp.com/goto/contacts/123456778 with DELETE request.

  1. Test Case 6: PUT request with empty input field.

cs3219-taskb's People

Contributors

kormingsoon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.