-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #757: reject posts without publication date #823
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this locally on Windows and it works. For anyone else wanting to test this, please remember to redis-cli flushall
or delete your redis image using docker image rm redis
(might need -f
to force delete).
- Set
API_URL=http://localhost:3000
in your.env
- Run
docker-compose up --build
- Run
npm run develop
localhost:8000
in browser
localhost:3000
still shows "My first feed" for some reason but it's not there in localhost:8000
src/backend/data/post.js
Outdated
try { | ||
this.published = new Date(datePublished); | ||
} catch (error) { | ||
throw new Error(`post has invalid publication date : ${datePublished}'`); | ||
} | ||
try { | ||
this.updated = new Date(dateUpdated); | ||
} catch (error) { | ||
throw new Error(`post has invalid date of last update: ${dateUpdated}'`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could have try and catch
inside of toDate
and throw there. Also, toDate
checks if what's passed is already an instance of Date
, I think it'd be useful to keep it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what criteria does Date
follow to throw? I looked around to see how people check for invalid dates and I found some interesting suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made some changes in 24a4fd4, let me know what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delay. Made the requested changes in 225ef1a, please let me know what you think!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally with your branch 👍
Issue This PR Addresses
Fixes #757
Type of Change
Description
Checklist