This repository was archived by the owner on Aug 14, 2025. It is now read-only.
Add order service and database handlers #4
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant changes to the database schema, database layer, and order handling logic, along with updates to the toolset for order management. The changes include the addition of new database tables and enums, refactoring of database interfaces and implementations, and the introduction of a new handler for managing orders. Below is a summary of the most important changes grouped by theme.
Database Schema and Configuration Updates:
order,product,order_item) and an enum (orderStatusEnum) to support order management. These include fields for relationships, timestamps, and additional metadata. ([[1]](https://github.com/PoliEats/Backend/pull/4/files#diff-0418d6df92492cd6ccd0cdc243d498a3640952877ebd62c6373329d7bf38460eL1-R7),[[2]](https://github.com/PoliEats/Backend/pull/4/files#diff-0418d6df92492cd6ccd0cdc243d498a3640952877ebd62c6373329d7bf38460eR33-R61))drizzle.config.tsfile to reflect the new schema file location (src/database/schema.ts). ([drizzle.config.tsL5-R5](https://github.com/PoliEats/Backend/pull/4/files#diff-d4e1c765f5d43acb9c59d87b520418289031da3fe52f5031041502b1250509c8L5-R5))Database Layer Enhancements:
PostgresDatabaseclass implementingIDatabase, with methods for CRUD operations and advanced query capabilities. ([src/database/PostgresDatabase.tsR1-R83](https://github.com/PoliEats/Backend/pull/4/files#diff-84d843dff943834903b3db9f368080eb8efa5d2266ea23db0d5782644e695e1bR1-R83))MockDatabaseclass to improve ID generation logic and added debug logging for query results. ([[1]](https://github.com/PoliEats/Backend/pull/4/files#diff-76a9b8dfe33fdeb6e160cac0c903fc1e9c010c47d1a49d0009665fecec593aaeL32-R42),[[2]](https://github.com/PoliEats/Backend/pull/4/files#diff-76a9b8dfe33fdeb6e160cac0c903fc1e9c010c47d1a49d0009665fecec593aaeR83-R85),[[3]](https://github.com/PoliEats/Backend/pull/4/files#diff-76a9b8dfe33fdeb6e160cac0c903fc1e9c010c47d1a49d0009665fecec593aaeR100-R104))IDatabaseinterface to align with changes in thedrizzle-ormlibrary. ([src/interfaces/IDatabase.tsL28-R28](https://github.com/PoliEats/Backend/pull/4/files#diff-c5ab488a5fe71a9432aa7be6662769278b210569c9a4366637859549d6f0b570L28-R28))Order Handling Logic:
OrderHandlerclass to manage order creation, retrieval, updates, and deletion with proper error handling and user validation. ([src/handlers/OrderHandler.tsR1-R244](https://github.com/PoliEats/Backend/pull/4/files#diff-d2c332f37ea9ab2a7ceb48301f9eb978eb502720c928edd7829150832fa3dc5fR1-R244))IOrderandIOrderItemtypes to define the structure of orders and their items. ([src/interfaces/IOrder.tsR1-R17](https://github.com/PoliEats/Backend/pull/4/files#diff-9f4a69f396d7d638a094a4c13bbcd39eb1b5fcf540927391b12d0b48cd47ce8bR1-R17))Toolset and Integration Updates:
createOrdertool to integrate with the newOrderHandlerfor order creation, replacing the previous in-memory logic with database-backed functionality. ([[1]](https://github.com/PoliEats/Backend/pull/4/files#diff-94f1465c60f3e73761ee6a66e6ff15dbebe68291463b94f4b7d8737401e991deL3-L53),[[2]](https://github.com/PoliEats/Backend/pull/4/files#diff-94f1465c60f3e73761ee6a66e6ff15dbebe68291463b94f4b7d8737401e991deL75-R44),[[3]](https://github.com/PoliEats/Backend/pull/4/files#diff-94f1465c60f3e73761ee6a66e6ff15dbebe68291463b94f4b7d8737401e991deL108-R97))model.tsfile to include thegetOrderstool and updated the message format to include user details. ([[1]](https://github.com/PoliEats/Backend/pull/4/files#diff-808e86d7790a8533bc72e3c293111131e03375a5a42dc868fb175b617ed58a70L4-R11),[[2]](https://github.com/PoliEats/Backend/pull/4/files#diff-808e86d7790a8533bc72e3c293111131e03375a5a42dc868fb175b617ed58a70L26-R28))Environment and Configuration Cleanup:
.envfile to enhance security. ([.envL1-L6](https://github.com/PoliEats/Backend/pull/4/files#diff-e9cbb0224c4a3d23a6019ba557e0cd568c1ad5e1582ff1e335fb7d99b7a1055dL1-L6))