Giter Club home page Giter Club logo

mws-restaurant-stage-3's Introduction

Local Development API Server

Usage

Get Restaurants

curl "http://localhost:1337/restaurants"

Get Restaurants by id

curl "http://localhost:1337/restaurants/{3}"

Architecture

Local server

  • Node.js
  • Sails.js

Contributors

Getting Started

Development local API Server

Location of server = /server Server depends on node.js LTS Version: v6.11.2 , npm, and sails.js Please make sure you have these installed before proceeding forward.

Great, you are ready to proceed forward; awesome!

Let's start with running commands in your terminal, known as command line interface (CLI)

Install project dependancies
# npm i
Install Sails.js globally
# npm i sails -g
Start the server
# node server

You should now have access to your API server environment

debug: Environment : development debug: Port : 1337

Endpoints

GET Endpoints

Get all restaurants

http://localhost:1337/restaurants/

Get favorite restaurants

http://localhost:1337/restaurants/?is_favorite=true

Get a restaurant by id

http://localhost:1337/restaurants/<restaurant_id>

Get all restaurant reviews

http://localhost:1337/reviews/

Get a restaurant review by id

http://localhost:1337/reviews/<review_id>

Get all reviews for a restaurant

http://localhost:1337/reviews/?restaurant_id=<restaurant_id>

POST Endpoints

Create a new restaurant review

http://localhost:1337/reviews/
Parameters
{
    "restaurant_id": <restaurant_id>,
    "name": <reviewer_name>,
    "rating": <rating>,
    "comments": <comment_text>
}

PUT Endpoints

Favorite a restaurant

http://localhost:1337/restaurants/<restaurant_id>/?is_favorite=true

Unfavorite a restaurant

http://localhost:1337/restaurants/<restaurant_id>/?is_favorite=false

Update a restaurant review

http://localhost:1337/reviews/<review_id>
Parameters
{
    "name": <reviewer_name>,
    "rating": <rating>,
    "comments": <comment_text>
}

DELETE Endpoints

Delete a restaurant review

http://localhost:1337/reviews/<review_id>

If you find a bug in the source code or a mistake in the documentation, you can help us by submitting an issue to our Waffle Dashboard. Even better you can submit a Pull Request with a fix :)

Archival Note

This repository is deprecated; therefore, we are going to archive it. However, learners will be able to fork it to their personal Github account but cannot submit PRs to this repository. If you have any issues or suggestions to make, feel free to:

mws-restaurant-stage-3's People

Contributors

devnimi avatar forbiddenvoid avatar omaralbeik avatar sudkul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mws-restaurant-stage-3's Issues

Get all reviews endpoint only returns original 30 reviews

I tried creating new reviews and was able to get them back when I requested them by id, or for a specific restaurant id, but the endpoint that is supposed to return all the reviews does not include ones that were created after the original 30 that came pre-populated in the repo.

Difference in dataparsing after creating review

Expected:

{
    "id": 31,
    "restaurant_id": 1,
    "name": "Some Name",
    "createdAt": 1504095567183,
    "updatedAt": 1504095567183,
    "rating": 4,
    "comments": "<removed for readability>"
  }

Actual:

  {
    "id": 2,
    "restaurant_id": "1",
    "name": "Morgan",
     "rating": "5",
    "comments": "asdasd",
    "createdAt": "2018-04-13T19:24:52.518Z",
    "updatedAt": "2018-04-13T19:24:52.518Z",
    "id": 42
  }

Difference:
Rating is parsed as string.
Date format differs within the same dataset.
Restaurant_id parsed as string.

Impact: Breaking

This causes the client application to require special transforms just to ensure that the data is parsed correctly.

Inconsistent formatting in default DB values

Difference in default data:

Default datatype 1:

{
    "id": 1,
    "restaurant_id": 1,
    "name": "Steve",
    "createdAt": 1504095567183,
    "updatedAt": 1504095567183,
    "rating": 4,
    "comments": "<removed for readability>"
  }

Default datatype 2:

  {
    "id": 2,
    "restaurant_id": 1,
    "name": "Morgan",
    "createdAt": 1504095567183,
    "updatedAt": 1504095567183,
    "rating": "4",
    "comments": "<removed for readability>"
  }

Difference: Rating is parsed as string OR number.

Favourites endpoint writes incorrectly

Each restaurant object has a "is_favorite": false field. But if the PUT request http://localhost:1337/restaurants/<restaurant_id>/?is_favorite=true|false is run, the value becomes "is_favorite": "false". It becomes a string property from a boolean. This is causing parsing inconsistency in the web app.

Any chance of a PUT endpoint for restaurants?

I've just graduated from the MWS nanodegree and would like to extend the project further. Is there any chance of getting a PUT endpoint for restaurants (and maybe a POST endpoint as well, for new restaurants) so that we can update those? I've looked at the sails config and API files and don't see anything remotely resembling route configurations. Thanks!

Project ported to Sails v1

As you probably already know, Sails has released version 1 (currently 1.0.2 in npm) with some significant differences regarding the version on which this project was originally developed (0.12)

In case it's of your interest, I have adapted the project to work with Sails v1. You will find it in the "devel" branch of my fork:

https://github.com/frncesc/mws-restaurant-stage-3/tree/devel

The main changes introduced are:

  • Generated from scratch with sails-generate
  • Created custom models for "restaurants" and "reviews" in api/models
  • Created a simple API test suite in assets/test
  • Created two scripts (utils/generate-restaurants.js and utils/generate-reviews.js), useful for generating or restoring the restaurants API test data.

For more information, see the README.md file.

Minor issue in documentation

Well, I would like to address the owner of this project that you have repeated Get all reviews for a restaurant endpoint twice. Rest of the docs is awesome.

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.