Skip to content

CougarCS/CougarCS-Backend

Repository files navigation

CougarCS Backend

Offical backend of CougarCS.



Coverage Bugs Code Smells Maintainability Rating Security Rating Quality Gate Status CodeFactor

Libraries

Getting Started

  • Requirements

  • Installation

    • Install dependencies: yarn
    • Start local server: yarn server
    • The local server will start on http://localhost:4000
  • ENV Setup:

    • If you want to test out the payment or the reCAPTCHA, create a .env file in the root project folder.
    • You must have a Stripe, Google's reCAPTCHA, and SendGrid accounts.
    • NEW_RELIC_ENABLED must be disabled (NEW_RELIC_ENABLED=false) in development.
    • In the .env file include these:
    PORT
    SENDGRID_API_KEY
    CALENDAR_ID
    CALENDAR_API_KEY
    SHEET_API
    RECAPTCHA_SECRET_KEY
    STRIPE_API_KEY
    SENTRY_URL
    SEND_EMAIL
    NOTION_TOKEN
    NOTION_TUTOR_DB
    YOUTUBE_API_KEY
    YOUTUBE_PLAYLIST_ID
    COUGARCS_CLOUD_URL
    COUGARCS_CLOUD_ACCESS_KEY
    COUGARCS_CLOUD_SECRET_KEY
    NEW_RELIC_LICENSE_KEY
    NEW_RELIC_APP_NAME
    SUPABASE_URL
    SUPABASE_KEY
    
  • Docker Usage

  • Development Docker:

    • Build the image run docker build -t <image-name> -f Dockerfile.dev .
    • Create a container run docker run -dp <docker-port>:<external-port> --env-file .env <image-name>
  • Production Docker:

    • Build the image run docker build -t <image-name> .
    • Create a container run docker run -dp <docker-port>:<external-port> --env-file .env <image-name>
  • Linting

    • We use ESLint to fix styling and to enforce rules.
    • Run yarn run eslint-check to check linting issues in the code.
    • Run yarn run eslint-fix to auto-lint the code.secrets
    • ESLint runs on Github Action. ESLint must pass before pushing or during a pull request.
  • Scanning and Security Tools

  • Testing

    • We use Jest to do Unit testing.
    • We use Supertest to do intergeration test.
    • To run the tests locally:
      • Run yarn test
    • To test the coverage of the code:
      • Run yarn test:coverage
    • The tests are part of the CI/CD pipeline, if the test fails the CI/CD fails
    • The test coverage has to be 90% or greater and the coverage cannot drop below 5% for a PR or a push.
    • We use Coveralls to track the coverage.
  • Project Structure

    • server.js is the starting point of the application
    • src/api/routes/ has the routes of the applications
    • src/config/app.js sets up the middlewares
    • src/utils/api/calls.js has the api logic
    • src/utils/ has config for logger and caching
    • test has the unit and the intergeration tests