Open Nehal409 opened 5 months ago
We need one login-service for both foodie and chefs. It should live in auth controller/service.
The service name should not end with service
https://github.com/mhammadalam112/EhsaanTechMernMonth02/blob/d12d2a79eb332a4ad648b0753fb2d2df118ace58/src/services/foodie.js#L10
It should just say createFoodie
We don't need to fetch all the orders that are in our database.
The order table should have a status field. which can contain 'PENDING', 'FULFILLED' etc
We can simply return, no need to await https://github.com/mhammadalam112/EhsaanTechMernMonth02/blob/d12d2a79eb332a4ad648b0753fb2d2df118ace58/src/repositories/foodie.js#L10C5-L10C10
The same can be used everywhere just return instead of await https://github.com/mhammadalam112/EhsaanTechMernMonth02/blob/d12d2a79eb332a4ad648b0753fb2d2df118ace58/src/repositories/foodie.js#L5-L6
We don't need to fetch all the orders that are in our database.
Please confirm how should we display the orders to the chef? As per my understanding in the task sheet it was written to list Orders, so I have showed all the orders. Should i just filter it by 'pending' or any more condition?
We can simply return, no need to await https://github.com/mhammadalam112/EhsaanTechMernMonth02/blob/d12d2a79eb332a4ad648b0753fb2d2df118ace58/src/repositories/foodie.js#L10C5-L10C10
Is this because we are already using await in the service function? Because as per my understanding we should use await with database functions as it may take time to return the results sometimes. Please enlighten
we don't need this line https://github.com/mhammadalam112/EhsaanTechMernMonth02/blob/d12d2a79eb332a4ad648b0753fb2d2df118ace58/src/services/chef.js#L22C1-L22C47
then how should we extract the authorization token?
We don't need to fetch all the orders that are in our database. https://github.com/mhammadalam112/EhsaanTechMernMonth02/blob/d12d2a79eb332a4ad648b0753fb2d2df118ace58/src/services/order.js#L4
Please confirm how should we display the orders to the chef? As per my understanding in the task sheet it was written to list Orders, so I have showed all the orders. Should i just filter it by 'pending' or any more condition?
@mhammadalam112 To display chef orders, you must apply a join query between chef, dishes, and orders table because there is no direct relation between orders and chef's table. There is no need to display all the orders in the databse
Is this because we are already using await in the ser
@mhammadalam112 Yes, since the service function already handles waiting for asynchronous operations, there's no need to use "await" again in the repository.
then how should we extract the authorization token?
@mhammadalam112 On login, you would return the token as part of the response object. On the frontend, you can then retrieve the token from the response and add it to the request headers for later requests. In postman, you'll manually include the Authorization header for secured requests.
Issue Description
orders
table containsdishId
but lacks a relationship with thedishes
table.chefId
as a foreign key in thedishes
table).foodieId
in theorders
table).chefId
in theorders
table).knex.js
will handle errors.services
folder is unused. Controllers should only handle incoming requests and responses. Services should contain business logic, such as calling repository functions, implementing conditions, and throwing errors usinghapi/boom
.@hapi/boom
. Ensureexpress-async-errors
middleware is added toserver.js
for asynchronous error handling.userId
instead ofusername
in the request middleware.authenticationUser
function instead of creating another function (setFoodieUsername
).utils
function. Services should focus on business logic.