Vk#7
Conversation
…hed authService TypeScript warnings
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR appears to adjust frontend styling/font loading and reduce stale API responses by adding cache-busting to several GET requests, while also extending the backend vendor/rider APIs (delivery issues endpoint, richer order/profile payloads). It also includes a large set of backend build artifacts (Backend1/dist/**) and runtime logs.
Changes:
- Moved Google Fonts
@importout oftheme.cssintofonts.css. - Added cache-busting query params to several frontend API fetches and changed the frontend Axios default base URL port.
- Extended backend vendor and rider functionality (vendor delivery issues endpoint, added courier/user details in responses), plus added ad-hoc axios test scripts and committed backend build output.
Reviewed changes
Copilot reviewed 12 out of 147 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/styles/theme.css | Removed Google Fonts import from the theme stylesheet. |
| frontend/src/styles/fonts.css | Added Google Fonts import to fonts stylesheet. |
| frontend/src/app/contexts/AppContext.tsx | Added cache-busting to the refresh orders fetches. |
| frontend/src/app/components/CourierInterface.tsx | Added cache-busting to initial rider data fetches. |
| frontend/src/api/axios.ts | Changed Axios fallback base URL port to 5001. |
| Backend1/src/test_vendor.ts | Added ad-hoc axios script to register a vendor and hit vendor endpoints. |
| Backend1/src/test_order.ts | Added ad-hoc axios script to register a courier and fetch pending deliveries. |
| Backend1/src/services/authService.ts | Added TS casts (as string / as any) to JWT signing config. |
| Backend1/src/routes/vendorRoutes.ts | Added /me/delivery-issues vendor route. |
| Backend1/src/middlewares/authMiddleware.ts | Adjusted role normalization logic in requireRole. |
| Backend1/src/controllers/vendorController.ts | Included courier info in vendor orders; added getDeliveryIssues. |
| Backend1/src/controllers/riderController.ts | Added reviews to rider profile; included user info in active deliveries. |
| Backend1/logs/combined.log | Added additional runtime log entries. |
| Backend1/dist/utils/logger.js.map | Added compiled source map artifact. |
| Backend1/dist/utils/logger.js | Added compiled JS artifact. |
| Backend1/dist/utils/logger.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/utils/logger.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/utils/helpers.js.map | Added compiled source map artifact. |
| Backend1/dist/utils/helpers.js | Added compiled JS artifact. |
| Backend1/dist/utils/helpers.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/utils/helpers.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/utils/AppError.js.map | Added compiled source map artifact. |
| Backend1/dist/utils/AppError.js | Added compiled JS artifact. |
| Backend1/dist/utils/AppError.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/utils/AppError.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/test_vendor.js.map | Added compiled source map artifact. |
| Backend1/dist/test_vendor.js | Added compiled JS artifact. |
| Backend1/dist/test_vendor.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/test_vendor.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/test_order.js.map | Added compiled source map artifact. |
| Backend1/dist/test_order.js | Added compiled JS artifact. |
| Backend1/dist/test_order.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/test_order.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/services/paymentService.js.map | Added compiled source map artifact. |
| Backend1/dist/services/paymentService.js | Added compiled JS artifact. |
| Backend1/dist/services/paymentService.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/services/paymentService.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/services/orderService.js.map | Added compiled source map artifact. |
| Backend1/dist/services/orderService.js | Added compiled JS artifact. |
| Backend1/dist/services/orderService.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/services/orderService.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/services/notificationService.js.map | Added compiled source map artifact. |
| Backend1/dist/services/notificationService.js | Added compiled JS artifact. |
| Backend1/dist/services/notificationService.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/services/notificationService.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/services/authService.js.map | Added compiled source map artifact. |
| Backend1/dist/services/authService.js | Added compiled JS artifact. |
| Backend1/dist/services/authService.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/services/authService.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/server.js.map | Added compiled source map artifact. |
| Backend1/dist/server.js | Added compiled JS artifact. |
| Backend1/dist/server.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/server.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/seedOrders.js.map | Added compiled source map artifact. |
| Backend1/dist/seedOrders.js | Added compiled JS artifact. |
| Backend1/dist/seedOrders.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/seedOrders.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/routes/vendorRoutes.js.map | Added compiled source map artifact. |
| Backend1/dist/routes/vendorRoutes.js | Added compiled JS artifact. |
| Backend1/dist/routes/vendorRoutes.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/routes/vendorRoutes.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/routes/userRoutes.js.map | Added compiled source map artifact. |
| Backend1/dist/routes/userRoutes.js | Added compiled JS artifact. |
| Backend1/dist/routes/userRoutes.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/routes/userRoutes.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/routes/riderRoutes.js.map | Added compiled source map artifact. |
| Backend1/dist/routes/riderRoutes.js | Added compiled JS artifact. |
| Backend1/dist/routes/riderRoutes.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/routes/riderRoutes.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/routes/paymentRoutes.js.map | Added compiled source map artifact. |
| Backend1/dist/routes/paymentRoutes.js | Added compiled JS artifact. |
| Backend1/dist/routes/paymentRoutes.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/routes/paymentRoutes.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/routes/orderRoutes.js.map | Added compiled source map artifact. |
| Backend1/dist/routes/orderRoutes.js | Added compiled JS artifact. |
| Backend1/dist/routes/orderRoutes.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/routes/orderRoutes.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/routes/authRoutes.js.map | Added compiled source map artifact. |
| Backend1/dist/routes/authRoutes.js | Added compiled JS artifact. |
| Backend1/dist/routes/authRoutes.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/routes/authRoutes.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/routes/adminRoutes.js.map | Added compiled source map artifact. |
| Backend1/dist/routes/adminRoutes.js | Added compiled JS artifact. |
| Backend1/dist/routes/adminRoutes.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/routes/adminRoutes.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/middlewares/validateRequest.js.map | Added compiled source map artifact. |
| Backend1/dist/middlewares/validateRequest.js | Added compiled JS artifact. |
| Backend1/dist/middlewares/validateRequest.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/middlewares/validateRequest.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/middlewares/uploadMiddleware.js.map | Added compiled source map artifact. |
| Backend1/dist/middlewares/uploadMiddleware.js | Added compiled JS artifact. |
| Backend1/dist/middlewares/uploadMiddleware.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/middlewares/uploadMiddleware.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/middlewares/errorMiddleware.js.map | Added compiled source map artifact. |
| Backend1/dist/middlewares/errorMiddleware.js | Added compiled JS artifact. |
| Backend1/dist/middlewares/errorMiddleware.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/middlewares/errorMiddleware.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/middlewares/authMiddleware.js.map | Added compiled source map artifact. |
| Backend1/dist/middlewares/authMiddleware.js | Added compiled JS artifact. |
| Backend1/dist/middlewares/authMiddleware.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/middlewares/authMiddleware.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/controllers/vendorController.js | Added compiled JS artifact. |
| Backend1/dist/controllers/vendorController.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/controllers/vendorController.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/controllers/userController.js.map | Added compiled source map artifact. |
| Backend1/dist/controllers/userController.js | Added compiled JS artifact. |
| Backend1/dist/controllers/userController.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/controllers/userController.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/controllers/riderController.js.map | Added compiled source map artifact. |
| Backend1/dist/controllers/riderController.js | Added compiled JS artifact. |
| Backend1/dist/controllers/riderController.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/controllers/riderController.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/controllers/paymentController.js.map | Added compiled source map artifact. |
| Backend1/dist/controllers/paymentController.js | Added compiled JS artifact. |
| Backend1/dist/controllers/paymentController.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/controllers/paymentController.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/controllers/orderController.js.map | Added compiled source map artifact. |
| Backend1/dist/controllers/orderController.js | Added compiled JS artifact. |
| Backend1/dist/controllers/orderController.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/controllers/orderController.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/controllers/authController.js.map | Added compiled source map artifact. |
| Backend1/dist/controllers/authController.js | Added compiled JS artifact. |
| Backend1/dist/controllers/authController.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/controllers/authController.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/controllers/adminController.js | Added compiled JS artifact. |
| Backend1/dist/controllers/adminController.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/controllers/adminController.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/config/env.js.map | Added compiled source map artifact. |
| Backend1/dist/config/env.js | Added compiled JS artifact. |
| Backend1/dist/config/env.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/config/env.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/config/db.js.map | Added compiled source map artifact. |
| Backend1/dist/config/db.js | Added compiled JS artifact. |
| Backend1/dist/config/db.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/config/db.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/config/cors.js.map | Added compiled source map artifact. |
| Backend1/dist/config/cors.js | Added compiled JS artifact. |
| Backend1/dist/config/cors.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/config/cors.d.ts | Added compiled type declaration artifact. |
| Backend1/dist/app.js.map | Added compiled source map artifact. |
| Backend1/dist/app.js | Added compiled JS artifact. |
| Backend1/dist/app.d.ts.map | Added compiled type map artifact. |
| Backend1/dist/app.d.ts | Added compiled type declaration artifact. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| generateAccessToken: (id: string, role: string) => jwt.sign({ id, role }, env.JWT_SECRET as string, { expiresIn: env.JWT_EXPIRES_IN as any }), | ||
| generateRefreshToken: (id: string) => jwt.sign({ id }, env.REFRESH_TOKEN_SECRET as string, { expiresIn: env.REFRESH_TOKEN_EXPIRES_IN as any }), |
There was a problem hiding this comment.
Using as any for expiresIn (and casting secrets to string) sidesteps type safety around JWT configuration. Since env.JWT_EXPIRES_IN is a string from a validated schema, consider typing it as jwt.SignOptions['expiresIn'] (or transforming/narrowing in env.ts) rather than any, so invalid values are caught at compile-time.
| import axios from 'axios'; | ||
|
|
||
| async function test() { | ||
| const api = axios.create({ baseURL: 'http://localhost:5001/api' }); | ||
|
|
||
| try { | ||
| const testEmail = `test_vendor_${Date.now()}@iitk.ac.in`; | ||
| const regRes = await api.post('/auth/register', { | ||
| name: 'Test Vendor Shop', | ||
| email: testEmail, | ||
| password: 'password123', | ||
| phone: `777${Date.now().toString().slice(-7)}`, | ||
| role: 'vendor' | ||
| }); | ||
|
|
||
| const token = regRes.data.data.accessToken; | ||
| console.log(`Registered NEW VENDOR: ${testEmail} with Role: ${regRes.data.data.user.role}`); | ||
|
|
||
| api.defaults.headers.common['Authorization'] = `Bearer ${token}`; | ||
|
|
||
| // Check Vendor profile | ||
| const profRes = await api.get('/vendors/me/profile'); | ||
| console.log('VENDOR PROFILE ID:', profRes.data.data.id, 'Status:', profRes.data.data.status); | ||
|
|
||
| // Check Vendor orders | ||
| const ordersRes = await api.get('/vendors/me/orders'); | ||
| console.log('VENDOR ORDERS RETURNED:', ordersRes.data.data.length); | ||
|
|
||
| } catch (err: any) { | ||
| if (err.response) { | ||
| console.error('ERROR RESPONSE STATUS:', err.response.status); | ||
| console.error('ERROR RESPONSE BODY:', JSON.stringify(err.response.data)); | ||
| } else { | ||
| console.error('ERROR:', err.message); | ||
| } | ||
| } | ||
| } | ||
| test(); |
There was a problem hiding this comment.
These ad-hoc axios scripts register new users/vendors against a hardcoded localhost baseURL and will be compiled into the production build when placed under src/. This can accidentally pollute dev/staging databases and bloats the shipped artifact. Please move them under a dedicated scripts/ or tests/ location (or remove) and ensure they aren’t included in the build output.
|
|
||
| const api = axios.create({ | ||
| baseURL: import.meta.env.VITE_API_URL || 'http://localhost:5000/api', | ||
| baseURL: import.meta.env.VITE_API_URL || 'http://localhost:5001/api', |
There was a problem hiding this comment.
The fallback baseURL now points to localhost:5001, but the backend env schema defaults PORT to 5000. If VITE_API_URL isn’t set, the frontend will call the wrong port and API requests will fail. Consider keeping the fallback aligned with the backend default (5000) or using a relative '/api' with a dev proxy to avoid hardcoding ports.
| import axios from 'axios'; | ||
|
|
||
| async function test() { | ||
| const api = axios.create({ baseURL: 'http://localhost:5001/api' }); | ||
|
|
||
| try { | ||
| // 1. Create a brand new Rider explicitly | ||
| const riderEmail = `test_rider_${Date.now()}@iitk.ac.in`; | ||
| const regRes = await api.post('/auth/register', { | ||
| name: 'Test Rider', | ||
| email: riderEmail, | ||
| password: 'password123', | ||
| phone: `888${Date.now().toString().slice(-7)}`, | ||
| role: 'courier' // Strictly Courier! | ||
| }); | ||
| const riderToken = regRes.data.data.accessToken; | ||
| console.log(`Registered NEW Rider: ${riderEmail}`); | ||
|
|
||
| // Fetch the pending deliveries using the Rider JWT | ||
| api.defaults.headers.common['Authorization'] = `Bearer ${riderToken}`; | ||
| const pendingRes = await api.get('/riders/deliveries/pending'); | ||
| console.log('RIDER PENDING ORDERS RETURNED:', pendingRes.data.data.length); | ||
|
|
||
| if (pendingRes.data.data.length > 0) { | ||
| console.log('FIRST PENDING ORDER VENDOR ID:', pendingRes.data.data[0].vendorId); | ||
| } | ||
|
|
||
| } catch (err: any) { | ||
| console.error('ERROR RESPONSE:', err.response?.data || err.message); | ||
| } | ||
| } | ||
| test(); |
There was a problem hiding this comment.
This ad-hoc axios script (hardcoded localhost baseURL, creates users) is located under src/, so it will be compiled and shipped with the backend build. Please move it out of src/ (e.g., scripts/), or convert it into a proper Jest/Supertest test with cleanup to avoid persistent DB pollution.
| router.get('/me/reviews', vendorController.getVendorReviews); | ||
| router.get('/me/analytics', vendorController.getVendorAnalytics); | ||
| router.get('/me/delivery-issues', vendorController.getDeliveryIssues); |
There was a problem hiding this comment.
New vendor endpoint /me/delivery-issues is added, but there’s no test coverage for it. Since the repo already has Jest/Supertest coverage for vendor routes, please add a test that asserts the route is protected (401 without auth) and returns the expected shape for an authenticated vendor.
| const cacheBust = `?t=${Date.now()}`; | ||
| if (currentUser.role === 'CUSTOMER' || currentUser.role === 'user') { | ||
| try { | ||
| const res = await api.get('/users/orders'); | ||
| const res = await api.get('/users/orders' + cacheBust); | ||
| setOrders(res.data.data); |
There was a problem hiding this comment.
Cache-busting is appended via string concatenation ("/users/orders" + cacheBust). This will break if the URL ever gains its own query string (you’d end up with multiple '?'). Prefer using Axios' params option (or URLSearchParams) so query params merge safely.
| const cacheBust = `?t=${Date.now()}`; | ||
| const [pendRes, actRes, histRes, earnRes, feedRes] = await Promise.all([ | ||
| api.get('/riders/deliveries/pending').catch(e => ({ data: { data: [] }})), | ||
| api.get('/riders/deliveries/active').catch(e => ({ data: { data: [] }})), | ||
| api.get('/riders/deliveries/history').catch(e => ({ data: { data: [] }})), | ||
| api.get('/riders/earnings').catch(e => ({ data: { data: null }})), | ||
| api.get('/riders/feedbacks').catch(e => ({ data: { data: { feedbacks: [], avgRating: "5.0" } } })) | ||
| api.get('/riders/deliveries/pending' + cacheBust).catch(e => ({ data: { data: [] }})), | ||
| api.get('/riders/deliveries/active' + cacheBust).catch(e => ({ data: { data: [] }})), | ||
| api.get('/riders/deliveries/history' + cacheBust).catch(e => ({ data: { data: [] }})), | ||
| api.get('/riders/earnings' + cacheBust).catch(e => ({ data: { data: null }})), | ||
| api.get('/riders/feedbacks' + cacheBust).catch(e => ({ data: { data: { feedbacks: [], avgRating: "5.0" } } })) |
There was a problem hiding this comment.
cacheBust is only applied in the initial Promise.all fetches, but the 5s polling call below still hits /riders/deliveries/pending without it. If the intent is to avoid stale cached responses, the polling request needs the same approach (or switch to a cache-control header / axios params).
No description provided.