Skip to content

Nikko Lab 12#12

Open
npisciotti1 wants to merge 4 commits intocodefellows-javascript-401d13:masterfrom
npisciotti1:master
Open

Nikko Lab 12#12
npisciotti1 wants to merge 4 commits intocodefellows-javascript-401d13:masterfrom
npisciotti1:master

Conversation

@npisciotti1
Copy link

No description provided.

'use strict';

const createError = require('http-errors');
const debug = require('debug');
Copy link

@jalleng jalleng Mar 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add the extension on to this. ('guitar:error-middleware');

const Guitar = module.exports = function(name, type, make) {
if(!name) throw createError(400, 'bad request');
if(!type) throw createError(400, 'bad request');
if(!make) throw createError(400, 'bad request');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could make these a little more explicit. Think of the end user and how an error could be more useful to them.

.catch( err => Promise.reject(createError(404, err.message)))
.then( guitar => {
for (var prop in guitar) {
if(_guitar[prop]) guitar[prop] = _guitar[prop];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might allow the user to change the id on their guitar object. Which could mess up how it is being stored in your db. It is a good idea to ignore attempts to update the id by continuing if (prop === 'id').


const Router = require('express').Router;
const jsonParser = require('body-parser').json();
const debug = require('debug');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add on the debug extension here ('guitar:guitar-router')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants