Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server Side File Reorganization #397

Closed
wants to merge 35 commits into from

Conversation

michelleli01
Copy link
Contributor

@michelleli01 michelleli01 commented Sep 12, 2023

Summary

This pull request is the beginning of a movement to make CU Reviews a more readable, easier to understand code base by structuring and organizing files in more approachable formats.

Within the /server file path, it's divided into a db folder and an endpoints folder.

DB Folder

The db folder contains all relevant files in terms of server side database schemas as well as the testing file for initializing the database (should be deprecated in the future).

Endpoints Folder

The endpoints folder contains all files for relevant endpoints. For example, within the admin folder, there are files that are relevant for the admin page such as various actions and charts (this needs to be heavily refactored for future use). At its core, each subfolder within the endpoints folder describes the relevant routes for some backend functionality. For example, the profile subfolder contains all relevant routes that are needed for the profile feature and the review subfolder contains all relevant routes that are needed for reviews (i.e leaving a review, finding a review helpful, etc). The core files are the routes.ts, types.ts, and functions.ts files.

The functions.ts files contain all necessary helper functions that may be utilized in the routes.ts file. The purpose of this is to abstract away the functions and modularize this for easier readability and accessibility. The types.ts files contain all necessary interfaces, constants, and types created for the relevant routes.ts file. Again, making it easier to find exactly where to add necessary types. The routes.ts files should contain the core functionality of the API endpoint where the functions.ts and types.ts files are used as support.

Tests Folder

All test suites and the creation of the Jest test server is located in the /test folder for ease of access in adding new tests to relevant testing files.

Utils Folder

The utils folder contains some global helper functions (will be rearranged and deprecated).

Progress

  • Separate endpoints into routes.ts, functions.ts, and utils.ts files
  • Split up utils.ts file into appropriate files
  • remove deprecated functions
  • admin folder
    • combine AdminActions.ts and AdminChart.ts
    • fix functionality for AdminActions.ts and AdminChart.ts
  • auth folder
    • move getVerificationTicket function to functions.ts
    • add getting verification ticket into some sort of global context
  • profile folder
  • review folder
  • search folder

Test Plan

Tested locally ensuring functionality remains the same and unit tests pass.

Notes

For future changes and notes:

  • Refactor DB functions
  • Refactor Admin page functions
  • Refactor authentication
  • Refactor search functionality

Breaking Changes

@michelleli01 michelleli01 requested a review from a team as a code owner September 12, 2023 05:32
@dti-github-bot
Copy link
Member

dti-github-bot commented Sep 12, 2023

[diff-counting] Significant lines: 3291. This diff might be too big! Developer leads are invited to review the code.

@michelleli01 michelleli01 removed the request for review from epicdragon44 September 12, 2023 06:52
@michelleli01 michelleli01 changed the title [WIP] Restructure server files [WIP] Server Side Refactoring Sep 12, 2023
@michelleli01 michelleli01 changed the title [WIP] Server Side Refactoring [WIP] Server Side File Reorganization Sep 12, 2023
Copy link
Collaborator

@wizhaaa wizhaaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this is a lot! Thanks for the hard work. The 3 a.m. code grind is real. I think with the backend, I am still familiarizing myself with how it is set up but will try my best to comment and give some feedback.

Regarding basic formatting and structure, I wrote a little write-up on the notion here: my notes on phase 1

I have not truly looked into much, but I am wondering why we utilize the register function as opposed to something simpler. Is there a certain reason for this? I feel it abstracts too much away in a function with not much room for customizability.

server/server.ts Outdated Show resolved Hide resolved
@dti-github-bot dti-github-bot changed the title [WIP] Server Side File Reorganization Server Side File Reorganization Sep 26, 2023
@dti-github-bot dti-github-bot removed the request for review from epicdragon44 September 26, 2023 17:18
@leihelen
Copy link
Contributor

leihelen commented Oct 2, 2023

I think there is a lot of code which is really overwhelming, especially since I'm so new to everything, and I think you've made really good progress restructuring the code to be easier to understand.

@michelleli01 michelleli01 deleted the michelle/restructure-server branch January 8, 2024 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants