Giter Club home page Giter Club logo

cs130-fall21's Introduction

Repository Structure

This is the repository for the CS130 project Grand Valet. The folder frontend contains the implementation of the frontend web application using React. The folder backend contains the implementation of the web server using Express. The test folder contains the unit tests for the backend, implemented with Python.

Application API Documentation

In this section, we describe the APIs of the application in detail. Our working API consists of two parts: the communication REST API between frontend and backend (Server), and the data passing API between the backend and the Database (Database). The API for the Database is automatically generated by JSDoc, and the API for the Server is written in a similar style since the Server does not use object-oriented programming.

Database

Class wrapping database operations.

Kind: global class

Database.connect()

Connect the database

Kind: static method of Database

Database.db(dbName) ⇒ database

Database wrapper

Kind: static method of Database
Returns: database - - Database for MongoDB operations.

Param Type Description
dbName string Name of the database.

Database.close()

Close the connection

Kind: static method of Database

Database.store_user(body)

Stores a user

Kind: static method of Database

Param Type Description
body User JSON of a user file.

Database.read_user(username) ⇒ User

Reads a user

Kind: static method of Database
Returns: User - - JSON of the requested user file.

Param Type Description
username string Username of the requested user.

Database.read_activeHubs() ⇒ Array.<Hub>

Returns all currently active hubs.

Kind: static method of Database
Returns: Array.<Hub> - - Array of JSON of currently active hubs.

Database.read_nearbyHubs(loc, radius) ⇒ Array.<Hub>

Reads nearby hubs

Kind: static method of Database
Returns: Array.<Hub> - - Array of JSON of hubs satisfying the query.

Param Type Description
loc coordinates Cordinates of the center of the search.
radius number Radius of the search in miles.

Database.read_hub(hubId) ⇒ Hub

Reads a hub

Kind: static method of Database
Returns: Hub - - JSON of the requested hub.

Param Type Description
hubId number ID of the requested hub.

Database.store_hub(body)

Stores a hub

Kind: static method of Database

Param Type Description
body Hub JSON of a hub file.

Database.schedule_jobs()

Schedule unassigned jobs that are within 1 hr from scheduled time.

Kind: static method of Database

Database.read_assignedJobs(username) ⇒ Array.<Job>

Reads jobs assigned to a driver and assign jobs using schedule_jobs.

Kind: static method of Database
Returns: Array.<Job> - - Array of JSON of jobs assigned to the driver.

Param Type Description
username string Username of the requested driver.

Database.read_job(jobId) ⇒ Job

Reads a job and assign jobs using schedule_jobs.

Kind: static method of Database
Returns: Job - - JSON of the requested job.

Param Type Description
jobId number ID of the requested job.

Database.store_job(body)

Stores a job

Kind: static method of Database

Param Type Description
body Job JSON of a job file.

Database.read_maxMaxJobId() ⇒ number

Reads the currect maximum jobId

Kind: static method of Database
Returns: number - - Currect maximum jobId.

Database.read_maxMaxHubId() ⇒ number

Reads the currect maximum hubId

Kind: static method of Database
Returns: number - - Currect maximum hubId.

Server

The Backend.

GET /login()

Returns an HTML page containing an HTML form with three input elements: username, usertype, and password. When the user presses the submit button, the page should issue a request POST /login with username=:username&usertype=:usertype&password=:password in the body.

Kind: static method of Server

POST /login(username, usertype, password)

Checks that the provided username, usertype, and password matches the record. If the provided information does not match, returns 401 return code. Otherwise, set an authorization session cookie and return 200.

Kind: static method of Server

Param Type Description
username string User name
usertype string "user" or "driver"
password string Password

GET /api/hubs(hubid=null, long=null, lat=null, rad=null) ⇒ Array.<Hub>

Returns the information of the requested hub(s). If hubid is null, return all the active hubs in the database. If long, lat, and rad are also given, only return active hubs that are in the circle centered at (long, lat) with radius rad.

Kind: static method of Server

Returns: Array.<Hub> - - Array of JSON of hubs

Param Type Description
hubid number The unique hub id
long number A number specifying the longitude of the center of search range
lat number A number specifying the latitude of the center of search range
rad number A number specifying the circle of search range

POST /api/hubs(hubId, description, startTime, endTime, location=null) ⇒ Hub

Create or update a hub entry. If hubId is 0, insert a new hub and return 201. If hubId> 0 and hubIdrecord exists, update the existing hub entry by overwriting the description, location, startTime, endTime fields in the request. Return 200. Otherwise, return 404.

Kind: static method of Server

Returns: Hub - - The updated or created Hub

Param Type Description
hubid number The unique hub id
description string Description of the hub
startTime startTime When the hub starts
endTime endTime When the hub ends
location array Longitude and Latitude of the hub (can be null)

GET /api/jobs(username=null, jobid=null) ⇒ Array.<Job>

Get all the jobs associated with username or jobid. If username or jobid does not exist, return 404. If jobid is not null, return the job corresponding to the jobid. If username exists and correspond to a driver, return a JSON containing a sorted list of jobs. If username exists and correspond to a customer, return a JSON containing a single job.

Kind: static method of Server

Returns: Array.<Job> - - Array of JSON of jobs

Param Type Description
username string User name
jobid number The unique job id

POST /api/jobs(data) ⇒ Job

Create a new job or update an existing job. First construct a Job object using the data given. If the jobId is 0, create a new job and add it to the database and return the job with code 201. Otherwise, update the status of an existing job and return the hub with code 200. If the jobId is not 0 and the job is not found, return 400.

Kind: static method of Server

Returns: Job - - The updated or created job

Param Type Description
data JSON The data corresponding to a new job or an existing job.

cs130-fall21's People

Contributors

jingnongqu avatar xiaowu0162 avatar mariomzhang avatar leoliu00529 avatar jaqueline-lu avatar ericliucook 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.