GithubHelp home page GithubHelp logo

carolina-gomez / starter-constellations-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thinkful-ed/starter-constellations-server

0.0 0.0 0.0 66 KB

Starter code for student exercises in the Flex and Immersive Web Development programs.

starter-constellations-server's Introduction

Starter Code: Constellations Server

This server is intended to be run for some checkpoints in the Thinkful curriculum. If you have trouble getting the server to run, reach out to your mentor.

Installation Instructions

  1. Fork this repository by clicking the Fork button at the top right of the page.
  2. Clone this repository.
  3. cd into the newly created directory.
  4. Run npm install.
  5. Run npm start.

Running npm start will spin up a server on port 5000.

Description

The Constellations Server provides a RESTful API through which you can request and modify information about constellations.

In general, you should only need to access the routes described below.

GET /constellations

Making a GET request to /constellations will return an array of objects, where each object is a constellation.

Example Request

GET http://localhost:5000/constellations

Example Response

[
  {
    "id": "UEUrlfX",
    "name": "Columba",
    "meaning": "Dove",
    "starsWithPlanets": 3,
    "quadrant": "SQ1"
  },
  {
    "id": "zb8QvVt",
    "name": "Crater",
    "meaning": "Cup",
    "starsWithPlanets": 10,
    "quadrant": "SQ2"
  }
]

GET /constellations/:id

Making a GET request to /constellations/:id, where :id is an ID of one of the constellations, will return a single object that represents the specified constellation.

If the constellation cannot be found by the ID, the server will return an error message of 404 Not found.

Example Request

GET http://localhost:5000/constellations/UEUrlfX

Example Response

{
  "id": "UEUrlfX",
  "name": "Columba",
  "meaning": "Dove",
  "starsWithPlanets": 3,
  "quadrant": "SQ1"
}

POST /constellations

Making a POST request to /constellations, and including a request body, will return a single object that represents the newly created constellation.

There is no specific validation that is a part of the server, so you can create a record with any number of keys. Newly created records will automatically generate an ID.

Example Request

POST http://localhost:5000/constellations
{
  "name": "Camelopardalis",
  "meaning": "Giraffe",
  "starsWithPlanets": 7,
  "quadrant": "SQ1"
}

Example Response

{
  "id": "IVU9de",
  "name": "Camelopardalis",
  "meaning": "Giraffe",
  "starsWithPlanets": 7,
  "quadrant": "SQ1"
}

PUT /constellations/:id

Making a PUT request to /constellations/:id, where :id is the ID of a constellation, and including a request body, will replace the existing constellation with the information included in the request body.

There is no specific validation that is a part of the server, so you can add whatever keys you want.

If the constellation cannot be found by the ID, the server will return an error message of 404 Not found.

Example Request

PUT http://localhost:5000/constellations/IVU9de
{
  "name": "Camelopardalis",
  "meaning": "Giraffe",
  "starsWithPlanets": 7,
  "quadrant": "NQ2"
}

Example Response

{
  "id": "IVU9de",
  "name": "Camelopardalis",
  "meaning": "Giraffe",
  "starsWithPlanets": 7,
  "quadrant": "NQ2"
}

DELETE /constellations/:id

Making a DELETE request to /constellations/:id, where :id is the ID of a constellation, will remove the specified constellation from the collection. An empty object will be returned.

If the constellation cannot be found by the ID, the server will return an error message of 404 Not found.

Example Request

DELETE http://localhost:5000/constellations/IVU9de

Example Response

{}

Tips

Making requests to the server may modify the data! If you want to reset your data back to its previous state, you can run the following command in this repository's folder.

git checkout db.json

This will effectively "undo" changes made to the database.

starter-constellations-server's People

Contributors

bwreid avatar carolina-gomez avatar gabrielsanchez 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.