-
Notifications
You must be signed in to change notification settings - Fork 1
Completed core functionality (ZACHARY NORCROSS) #4
base: intern-practice
Are you sure you want to change the base?
Conversation
| const app = express(); | ||
|
|
||
| //TODO: Add an express router | ||
| const router = express.Router(); |
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.
👍
server/app.js
Outdated
| // Setup middleware so we can read the requests body | ||
| app.use(express.json()); | ||
| app.use(express.urlencoded({ extended: true })); | ||
| app.use("/", router); // so router can work |
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.
Move this router into a new file?
server/app.js
Outdated
|
|
||
| // TASK 1 | ||
| router.get("/mealtimes", (req, res) => { | ||
| if (req.query.query == undefined) { |
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.
if (req.query.query) is better.
But Preferred:
const { query } = req.query;
server/app.js
Outdated
| if (req.query.query == undefined) { | ||
| // if no query is given in the url | ||
| resultingJSON = { status: "success", data: [] }; | ||
| resultingJSON.data = Dates; |
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.
Try to use immutability!
server/app.js
Outdated
| if (req.query.query == undefined) { | ||
| // if no query is given in the url | ||
| resultingJSON = { status: "success", data: [] }; | ||
| resultingJSON.data = stopWordList; |
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.
Same thing as above.
server/app.js
Outdated
| if (isStopWord(inputString)) { | ||
| // if we have a stop word | ||
| data.type = "stopword"; | ||
| var word = getStopWord(inputString); |
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.
Try not to use var -> use const
server/app.js
Outdated
|
|
||
| function isDateWord(inputString) { | ||
| for (var i = 0; i < Dates.length; i++) { | ||
| if (Dates[i].names.includes(inputString.toLowerCase())) { |
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.
Is there a way to simplify this?
server/models/StopWord.js
Outdated
| const isStopWord = (word) => { | ||
| const isStopWord = word => { | ||
| //TODO Fill this in | ||
| if (stopWordList.includes(word.toLowerCase())) { |
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.
Can you simplify this?
|
Looks good!
|
No description provided.