GithubHelp home page GithubHelp logo

gt-scheduler / backend Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 1.0 237 KB

API server that is used to augment the functionality of the website/crawler

Home Page: https://gt-scheduler.azurewebsites.net/

License: GNU Affero General Public License v3.0

TypeScript 100.00%

backend's Introduction

GT Scheduler Backend

Express API server used to augment the functionality provided in the GT scheduler website/crawler.

To report a bug or request a new feature, please create a new Issue in the GT Scheduler website repository.

๐Ÿ“ƒ License & Copyright Notice

This repository has been created as a part of the ongoing development of the GT Scheduler project, which was originally created by Jinseo Park.

The work in this repository is licensed under the AGPL v3.0 license.

Copyright (c) 2021 the Bits of Good "GT Scheduler" team

Starter

The repository was initialized using greenroach/express-ts-template, which is licensed under the MIT license.

๐Ÿ” Overview

The backend API is built using TypeScript (a typed superset of JavaScript) and Express to support some additional features included in the rest of the project. It also utilizes celebrate for runtime validation and morgan for HTTP logging.

To implement the feedback submission API, the backend validates and then forwards the submitted data from the frontend to Airtable, a free small-scale spreadsheet service that stores it (which only project owners have access to).

๐Ÿš€ Running Locally

Requisite software

  • Node.js (any recent version will probably work)
  • Installation of the yarn package manager version 1 (support for version 2 is untested)

Running the app

After cloning the repository to your local computer, run the following command in the repo folder:

yarn install

This may take a couple minutes and will create a new folder called node_modules with all of the dependencies installed within. This only needs to be run once.

Then, to build and run the backend API, run:

yarn run build
yarn start

The API should be online and serving at http://localhost:3030

Adding Airtable API integration

To connect with Airtable, first obtain a valid API key and base. Then, rename .env.example to .env, replacing the values within with your own.

Linting

The project uses pre-commit hooks using Husky and lint-staged to run linting (via ESLint) and formatting (via Prettier). These can be run manually from the command line to format/lint the code on-demand, using the following commands:

  • yarn run lint - runs ESLint and reports all linting errors without fixing them
  • yarn run lint:fix - runs ESLint and reports all linting errors, attempting to fix any auto-fixable ones
  • yarn run format - runs Prettier and automatically formats the entire codebase
  • yarn run format:check - runs Prettier and reports formatting errors without fixing them

Running while developing

The following command will run the server and automatically re-build the backend if any of the source files change.

yarn run watch-debug

Similar to yarn start, the API should be online and serving at http://localhost:3030

Using the debugger in VS Code (instructions from starter code)

Debugging is one of the places where VS Code really shines over other editors. Node.js debugging in VS Code is easy to setup and even easier to use. This project comes pre-configured with everything you need to get started.

When you hit F5 in VS Code, it looks for a top level .vscode folder with a launch.json file. In this file, you can tell VS Code exactly what you want to do:

{
  "type": "node",
  "request": "attach",
  "name": "Attach by Process ID",
  "processId": "${command:PickProcess}",
  "protocol": "inspector"
}

This is mostly identical to the "Node.js: Attach by Process ID" template with one minor change. We added "protocol": "inspector" which tells VS Code that we're using the latest version of Node which uses a new debug protocol.

With this file in place, you can hit F5 to attach a debugger. You will probably have multiple node processes running, so you need to find the one that shows node dist/server.js. Now just set your breakpoints and go!

๐Ÿ‘ฉโ€๐Ÿ’ป Contributing

The GT Scheduler project welcomes (and encourages) contributions from the community. Regular development is performed by the project owners (Jason Park and Bits of Good), but we still encourage others to work on adding new features or fixing existing bugs and make the registration process better for the Georgia Tech community.

More information on how to contribute can be found in the contributing guide.


Based on TypeScript Node Starter and Express Generator

backend's People

Contributors

jazeved0 avatar izou3 avatar arthelon avatar nhatnghiho avatar samarth52 avatar yatharth-b avatar nathangong avatar

Stargazers

 avatar Taye Beckford avatar Giam Nguyen avatar  avatar Victor Guyard avatar Aidan avatar Austin Jackson avatar Gabriel Britain avatar Jinseo Park avatar Jack DiMarco avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

skapoor68

backend's Issues

Add API Route to Proxy Seating Information Requests

Problem Description

Right now, the frontend requests seating information from Oscar in the following format:

https://oscar.gatech.edu/pls/bprod/bwckschd.p_disp_detail_sched?term_in=202102&crn_in=24143

However, due to restrictions created by their CORS policy, the request fails when sent from the gt-scheduler app, and as a result, we utilize a free CORS proxy called "cors-anywhere" that previously worked.

https://cors-anywhere.herokuapp.com/https://oscar.gatech.edu/pls/bprod/bwckschd.p_disp_detail_sched?term_in=202102&crn_in=24143

A couple months ago, however, it stopped working, and as a result, we need more control over the CORS proxy in order to make the requests to Oscar succeed and correctly obtain seating information.

Your Goal

This task involves bypassing the CORS restrictions present on the Oscar API route, and as such, has both an investigation and an implementation component:

  • Use a tool such as Postman or Curl to send example requests to the Oscar API until they succeed (by spoofing the headers with the required values)
  • Create an API route at /courses/{course}/seating that:
    • takes in the combined course subject + number (such as "CS 2340") in the {course} URL parameter (using URL encoding)
    • sends a request to Oscar using their API URL format and with the correct headers set
    • returns the response once it comes back from Oscar, just as it was formatted (at least for now)

Potentially Helpful Resources

Create feedback form submission API

Problem Description

Soon, the frontend will contain a feedback form widget that allows a user to submit a numeric integer rating (1-5) and some additional textual feedback directly from within the app. To use this, we want to create a simple API endpoint that will take the submitted feedback and forward it to an Airtable table that can be easily viewed by non-technical contributors.

Your Goal

This task involves creating an API endpoint that looks like the following:

POST /feedback

with a JSON body that contains:

{
  "rating": 3,
  "feedback": "Additional feedback"
}

Upon receiving this, the API should:

  • Impose some reasonable max length on the feedback
  • Validate that the rating is an integer and within the interval [1, 5] (inclusive)
  • Send a request using airtable.js to an existing Airtable table (TODO: create account to use and link to docs. The API documentation is interactive and created once you're logged in, so for now, feel free to create an account and a sample table to view the API docs).

Finally, you should make another PR in the gt-scheduler/website repo to integrate this functionality with the frontend in the form of making a simple axios call to the API endpoint when the feedback form is submitted (see Section.js#L66 for an example of making a request to the backend)

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.