4human-org / murphy-ecommerce-backend

Backend Repo for the Murphy E-Commerce App
2 stars 1 forks source link

File Structure Reorganization #20

Closed Calesi19 closed 4 months ago

Calesi19 commented 4 months ago

Changes to file structure to make it easier to add stuff to the app. No typescript was used.

CHANGES:

  1. The "routes" and "controllers" folders were created.

    • In the "routes" folder, the developer can define which endpoints trigger which functions.
    • In the "controller" folder, the developer can implement the logic of functions for endpoints.
    • This separation will allow easier use of middleware in the future.
  2. A "utils" folder was created with scripts to populate the database.

    • The "clearDatabase.mjs" script deletes all the products in the database.
    • The "populateDatabase.mjs" script inserts dummy products into the database.
    • This allows the developer to easily reset the database after testing API endpoints and changing data in the database. Read the README file inside "utils" folder for more details.
  3. A "models" folder was created, but not used in the app. Models can be used later to enforce a specific structure for the data the server handles. It can make sure certain fields have default values.

  4. "Items" was changed to "Products" to better reflect the data we are storing.

    • Endpoints were adjusted from "/items" to "/products", but the logic remains the same.

To run

  1. Clone Branch

  2. Run command:

    npm install
  3. Setup .env files

  4. Run command:

    nodemon app.mjs