Giter Site home page Giter Site logo

imagine-satellite's Introduction

imagine-satellite-api

Backend API service that returns the live information of satellites This project is for the Imagine Fellowships.

Introduction

This API is composed of 3 points, the main endpoint that returns all the satellites in the database, an endpoint that allows searching for satellites by name, and finally an endpoint to search for satellites by distance to a point.

As an extra, a user system was added, which allows adding new satellites with a unique key for each user.

Table of contents

Install

  • npm install

Testing

  • npm test

Run

  • npm start

Routes protocol

Auth

/auth/register

  • Method POST
  • Create a new user
  • Receives: username, password in body request
  • Returns:
    • On successful registration -> code 201, { auth: true, key }
    • On failed validation -> code 400, { auth: false, msg: [errors] }
    • If username already exist -> code 400, { auth: false, msg: "Your username already exist" }
    • On server error -> code 500, { auth: false, msg: "There was a problem registering your user" }

/auth/login

  • Method POST
  • Log in user to get their key
  • Receives: username, password in body request
  • Returns:
    • On successful log in -> code 200, { auth: true, key }
    • On failed validation -> code 400, { auth: false, msg: [errors] }
    • If the user does not exist or the password is incorrect -> code 400, { auth: false, msg: "Incorrect username or password" }
    • On server error -> code 500, { auth: false, msg: "There was a problem logging" }

Satellites

/satellite

  • Method POST
  • Create a new satellite
  • Receives: satellite in body request, key in query
  • Returns:
    • On successful create -> code 201, { created: true, msg: "Satellite created successfully" }
    • On failed validation -> code 400, { created: false, msg: [errors] }
    • If the user does not exist -> code 404, { created: false, msg: "User not found" }
    • On server error -> code 500, { created: false, msg: "There was a problem creating a satellite" }

  • Method GET
  • Get all satellites
  • Returns:
    • On successful action -> code 200, { [satellite] }
    • On empty list of satellites -> code 200, { msg: "There are no satellites in the database yet" }
    • On server errors -> code 500, { msg: "There was a problem getting satellites" }

/satelliteByName

  • Method GET
  • Get a specific satellite according to its name
  • Receives: name in query
  • Returns:
    • On successful action -> code 200, { satellite }
    • On failed validation -> code 400, { msg: [errors] }
    • If the satellite does not exist -> code 400, { msg: "Satellite 'name' not found" }
    • On server errors -> code 500, { msg: "There was a problem getting satellite" }

/satelliteByDistance

  • Method GET
  • Get all the satellites that are within a maximum distance d of (l1,l2)
  • Receives: l1, l2, d in query
  • Returns:
    • On successful action -> code 200, { satellitesInDistance: [satellites] }
    • On failed validation -> code 400, { msg: [errors] }
    • On empty list of satellites -> code 200, { msg: There are no satellites within d km of (l1,l2) }
    • On server error -> code 500, { msg: "There was a problem getting satellites" }

imagine-satellite's People

Contributors

franzavalla avatar

Watchers

James Cloos avatar  avatar

imagine-satellite's Issues

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.