Closed Maikxx closed 6 years ago
Well done!
npm run watch
or live
maybe?[ i]
in CSS work in your browser? 🤔mimetype === 'image/jpeg'
is either true or false, you could shorten the function to callback(null, mimetype == 'image/jpeg')
try
from try..catch
as small as possible, now there could be many errors going on here, instead of just the db.has
part!id
is invalid, db.removed
will also throw an error, this time uncaught, meaning it will crash the server(!name.length > 0 || undefined)
part looks weird! To check that name
has no a length
, use name.length < 1
or name.length === 0
or even !name.length
. Then, to check that name is undefined, use name === undefined
! In fact, you could use name && name.length && type && type.length
for this whole block.try { db.add(req.body) } catch (err) { /* 422*/; return; } /* 201 */
. The database already does all the validation stuff. Note that some stuff like checkboxes and radio’s need a change in data, but still! (for example, like this)Object.assign
instead of a loop to “patch” data!handleHttpError
and renderHtml
functions!
Shelter Maikel
I liked this exercise, although I think it was a bit much for one exercise. I can imagine a lot of people not going to be able to finish this in time, or maybe I went too hardcore on the validation of the form, not sure.
Anyhow, a good exercise to learn multer, bodyParser and express, I also used moment for validating the date via the form.