bug: backend fails to start because src/utils/logger.js is missing#1081
Open
sonusharma6-dsa wants to merge 2 commits into
Open
bug: backend fails to start because src/utils/logger.js is missing#1081sonusharma6-dsa wants to merge 2 commits into
sonusharma6-dsa wants to merge 2 commits into
Conversation
|
@sonusharma6-dsa is attempting to deploy a commit to the souma9830's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR primarily resolves backend startup failures by adding the missing backend/src/utils/logger.js module that is imported by the app and env checks. It also includes changes to upload persistence behavior and schema shape.
Changes:
- Add
backend/src/utils/logger.jsas a lightweight console wrapper with timestamped log levels. - Modify upload persistence to always create an
Uploadrecord (including anonymous uploads) and record the storedfilename. - Update the
Uploadschema to makeuseroptional and introduce a requiredfilenamefield.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| backend/src/utils/logger.js | Adds the previously-missing logger module required for backend imports to resolve. |
| backend/src/models/upload.model.js | Updates the upload schema to support anonymous uploads and to require/stash filename. |
| backend/src/controllers/upload.controller.js | Persists uploads for anonymous users and includes filename in stored metadata/response. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
+21
| /** | ||
| * Simple custom logger wrapping console methods with formatted timestamps and levels. | ||
| */ | ||
| const logger = { | ||
| info: (msg, ...args) => { | ||
| console.log(`[${new Date().toISOString()}] [INFO]: ${msg}`, ...args); | ||
| }, | ||
| warn: (msg, ...args) => { | ||
| console.warn(`[${new Date().toISOString()}] [WARN]: ${msg}`, ...args); | ||
| }, | ||
| error: (msg, ...args) => { | ||
| console.error(`[${new Date().toISOString()}] [ERROR]: ${msg}`, ...args); | ||
| }, | ||
| debug: (msg, ...args) => { | ||
| if (process.env.NODE_ENV !== 'production') { | ||
| console.debug(`[${new Date().toISOString()}] [DEBUG]: ${msg}`, ...args); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| export default logger; |
Comment on lines
+46
to
+54
| await Upload.create({ | ||
| user: req.user?.id || null, | ||
| fileId, | ||
| filename: req.file.filename, | ||
| originalName: req.file.originalname, | ||
| fileUrl, | ||
| mimeType: req.file.mimetype, | ||
| sizeBytes: req.file.size, | ||
| }); |
Comment on lines
5
to
9
| user: { | ||
| type: mongoose.Schema.Types.ObjectId, | ||
| ref: "User", | ||
| required: true, | ||
| required: false, // Optional for anonymous uploads | ||
| }, |
Owner
|
Open Source Programmed name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1032. Adds the missing backend logger.js utility wrapping standard console methods with formatted levels and ISO timestamps, enabling the backend service to start successfully.