From 0de3b920a74d8575c7b4a195b2c1ec2a71d115b2 Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Tue, 20 Dec 2016 16:32:22 -0800 Subject: [PATCH 01/11] all directories added, all .files added, dependencies installed --- .eslintrc | 21 +++++++++++ .gitignore | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++ gulpfile.js | 23 ++++++++++++ package.json | 38 +++++++++++++++++++ server.js | 0 5 files changed, 184 insertions(+) create mode 100644 .eslintrc create mode 100644 .gitignore create mode 100644 gulpfile.js create mode 100644 package.json create mode 100644 server.js diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..8dc6807 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,21 @@ +{ + "rules": { + "no-console": "off", + "indent": [ "error", 2 ], + "quotes": [ "error", "single" ], + "semi": ["error", "always"], + "linebreak-style": [ "error", "unix" ] + }, + "env": { + "es6": true, + "node": true, + "mocha": true, + "jasmine": true + }, + "ecmaFeatures": { + "modules": true, + "experimentalObjectRestSpread": true, + "impliedStrict": true + }, + "extends": "eslint:recommended" +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5eeb33e --- /dev/null +++ b/.gitignore @@ -0,0 +1,102 @@ + +# Created by https://www.gitignore.io/api/macos,node,vim,vim + +### macOS ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon +# Thumbnails +._* +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### Node ### +# Logs +logs +*.log +npm-debug.log* +node_modules + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + + + +### Vim ### +# swap +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +# session +Session.vim +# temporary +.netrwhist +*~ +# auto-generated tag files +tags + + +### Vim ### +# swap +# session +# temporary +# auto-generated tag files + +### project specific ### +temp +img/test.bmp diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..9bc33f9 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,23 @@ +'use strict'; + +const gulp = require('gulp'); +const eslint = require('gulp-eslint'); +const mocha = require('gulp-mocha'); + +gulp.task('test', function() { + gulp.src('./test/*-test.js', { read: false }) + .pipe(mocha({ reporter: 'spec' })); +}); + +gulp.task('lint', function() { + return gulp.src(['**/*.js', '!node_modules']) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}); + +gulp.task('dev', function() { + gulp.watch(['**/*.js', '!node_modules'], ['lint', 'task']); +}); + +gulp.task('default', ['dev']); diff --git a/package.json b/package.json new file mode 100644 index 0000000..04d2b51 --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "12-express_middleware", + "version": "1.0.0", + "description": "", + "main": "gulpfile.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "DEBUG='note*' mocha", + "start": "DEBUG='note*' node server.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/dbecker4130/12-express_middleware.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/dbecker4130/12-express_middleware/issues" + }, + "homepage": "https://github.com/dbecker4130/12-express_middleware#readme", + "dependencies": { + "bluebird": "^3.4.6", + "body-parser": "^1.15.2", + "debug": "^2.4.5", + "express": "^4.14.0", + "http-errors": "^1.5.1", + "morgan": "^1.7.0", + "node-uuid": "^1.4.7" + }, + "devDependencies": { + "chai": "^3.5.0", + "mocha": "^3.2.0", + "superagent": "^3.3.1" + } +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..e69de29 From baa70f2ef256754f7be3f6d59337f768262ba9c4 Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Tue, 20 Dec 2016 16:39:39 -0800 Subject: [PATCH 02/11] server works --- server.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server.js b/server.js index e69de29..1042672 100644 --- a/server.js +++ b/server.js @@ -0,0 +1,12 @@ +'use strict'; + +const express = require('express'); + +const PORT = 3000; + +const app = express(); + + +app.listen(PORT, () => { + console.log(`server live on: ${PORT}`); +}); From f33cbf834896a36a520c4b66b5f18793f448bd83 Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Tue, 20 Dec 2016 16:54:22 -0800 Subject: [PATCH 03/11] artist constructor complete, router constants added, beginning work on storage module --- model/artist.js | 18 ++++++++++++++++++ route/artist-router.js | 7 +++++++ server.js | 5 ++++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 model/artist.js create mode 100644 route/artist-router.js diff --git a/model/artist.js b/model/artist.js new file mode 100644 index 0000000..29b16ac --- /dev/null +++ b/model/artist.js @@ -0,0 +1,18 @@ +'use strict'; + +const uuid = require('node-uuid'); +const createError = require('http-errors'); +const debug = require('debug')('artist:artist'); +const storage = require('../lib/storage.js'); + +const Note = module.exports = function(name, genre) { + debug('artist constructor'); + + if(!name) throw createError(400, 'expected name'); + if(!genre) throw createError(400, 'expected genre'); + + this.id = uuid.v2(); + this.name = name; + this.genre = genre; + +}; diff --git a/route/artist-router.js b/route/artist-router.js new file mode 100644 index 0000000..ed47c19 --- /dev/null +++ b/route/artist-router.js @@ -0,0 +1,7 @@ +'use strict'; + +const Router = require('express').Router; +const jsonParser = require('body-parser').json(); +const debug = require('debug')('artist:artist-router.js'); +const Artist = require('../model/artist.js'); +const artistRouter = new Router(); diff --git a/server.js b/server.js index 1042672..3db4210 100644 --- a/server.js +++ b/server.js @@ -1,11 +1,14 @@ 'use strict'; +const morgan = require('morgan'); const express = require('express'); +const debug = require('debug')('note:server'); +const artistRouter = require('./route/artist-router.js'); const PORT = 3000; - const app = express(); +app.use(morgan('dev')); app.listen(PORT, () => { console.log(`server live on: ${PORT}`); From 14a8c2a76fb63bd77570b82b91571ecad9e0cfa9 Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Tue, 20 Dec 2016 17:08:26 -0800 Subject: [PATCH 04/11] storage module complete, Artist methods complete --- lib/storage.js | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ model/artist.js | 45 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 lib/storage.js diff --git a/lib/storage.js b/lib/storage.js new file mode 100644 index 0000000..31a65de --- /dev/null +++ b/lib/storage.js @@ -0,0 +1,54 @@ +'use strict'; + +const Promise = require('bluebird'); +const fs = Promise.promisifyAll(require('fs'), {suffix: 'Prom'}); +const createError = require('http-errors'); +const debug = require('debug')('music-artists:storage'); + +module.exports = exports = {}; + +exports.createItem = function(schemaName, item) { + debug('createItem'); + + if (!schemaName) return Promise.reject(createError(400, 'expected schema name')); + if (!item) return Promise.reject(createError(400, 'expected item')); + + let json = JSON.stringify(item); + return fs.writeFileProm(`${__dirname}/../data/${schemaName}/${item.id}.json`, json) + .then( () => item) + .catch( err => Promise.reject(createError(500, err.message))); +}; + +exports.fetchItem = function(schemaName, id) { + debug('fetchItem'); + + if(!schemaName) return Promise.reject(createError(400,'expected schema name')); + if(!id) return Promise.reject(createError(400, 'expected id')); + + return fs.readFileProm(`${__dirname}/../data/${schemaName}/${id}.json`) + .then(data => { + try { + let item = JSON.parse(data.toString()); + return item; + } catch (err) { + return Promise.reject(createError(500, err.message)); + } + }) + .catch( err => Promise.reject(createError(404, err.message))); +}; + +exports.deleteItem = function(schemaName, id) { + debug('deleteItem'); + + if (!schemaName) return Promise.reject(createError(400, 'expected schema name')); + if (!id) return Promise.reject(createError(400, 'expected id')); + + return fs.unlinkProm(`${__dirname}/../data/${schemaName}/${id}.json`) + .catch( err => Promise.reject(createError(404, err.message))); +}; + +exports.availIDs = function(schemaName) { + return fs.readdirProm(`${__dirname}/../data/${schemaName}`) + .then ( files => files.map(name => name.split('.json')[0])) + .catch( err => Promise.reject(createError(404, err.message))); +}; diff --git a/model/artist.js b/model/artist.js index 29b16ac..18b8e0b 100644 --- a/model/artist.js +++ b/model/artist.js @@ -5,7 +5,7 @@ const createError = require('http-errors'); const debug = require('debug')('artist:artist'); const storage = require('../lib/storage.js'); -const Note = module.exports = function(name, genre) { +const Artist = module.exports = function(name, genre) { debug('artist constructor'); if(!name) throw createError(400, 'expected name'); @@ -16,3 +16,46 @@ const Note = module.exports = function(name, genre) { this.genre = genre; }; + +Artist.createArtist = function(_artist) { + debug('createArtist'); + + try { + let artist = new Artist(_artist.name, _artist.genre); + return storage.createItem('artist', artist); + } catch (err) { + return Promise.reject(createError(400, err.message)); + } +}; + +Artist.fetchArtist = function(id) { + debug('fetchArtist'); + + return storage.fetchItem('artist', id); +}; + +Artist.updateArtist = function(id, _artist) { + debug('updateArtist'); + + return storage.fetchItem('artist', id) + .catch( err => Promise.reject(createError(404, err.message))) + .then( artist => { + for (var prop in artist) { + if (prop === 'id') continue; + if (_artist[prop]) artist[prop] = _artist[prop]; + } + return storage.createItem('artist', artist); + }); +}; + +Artist.deleteArtist = function(id) { + debug('deleteArtist'); + + return storage.deleteItem('artist', id); +}; + +Artist.fetchIDs = function() { + debug('fetchIDs'); + + return storage.availIDs('artist'); +}; From 4393d88e5a352faa3b1f1ebb2ad428c590f12287 Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Tue, 20 Dec 2016 17:14:47 -0800 Subject: [PATCH 05/11] cors middleware added to allow access to headers and origin --- lib/cors-middleware.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 lib/cors-middleware.js diff --git a/lib/cors-middleware.js b/lib/cors-middleware.js new file mode 100644 index 0000000..6661797 --- /dev/null +++ b/lib/cors-middleware.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function(req, res, next) { + res.append('Access-Control-Allow-Origin', '*'); + res.append('Access-Control-Allow-Headers', '*'); + next(); +}; From 85c2169961c2fb839eaa000c834b06353a5f046e Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Tue, 20 Dec 2016 17:22:07 -0800 Subject: [PATCH 06/11] err-middleware added to throw internal server errors and user errors --- lib/err-middleware.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/err-middleware.js diff --git a/lib/err-middleware.js b/lib/err-middleware.js new file mode 100644 index 0000000..fb7ee59 --- /dev/null +++ b/lib/err-middleware.js @@ -0,0 +1,21 @@ +'use strict'; + +const createError = require('http-errors'); +const debug = require('debug')('artist:err-middleware'); + +module.exports = function(err, req, res, next) { + console.error(err.message); + + if (err.status) { + debug('user error'); + + res.status(err.status).send(err.name); + next(); + return; + } + + debug('server error'); + err = createError(500, err.message); + res.status(err.status).send(err.name); + next(); +}; From 6d8b5d1f65ef3685b41c7fee182520935c019154 Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Tue, 20 Dec 2016 17:34:56 -0800 Subject: [PATCH 07/11] Artist router complete --- route/artist-router.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/route/artist-router.js b/route/artist-router.js index ed47c19..8d11e16 100644 --- a/route/artist-router.js +++ b/route/artist-router.js @@ -5,3 +5,37 @@ const jsonParser = require('body-parser').json(); const debug = require('debug')('artist:artist-router.js'); const Artist = require('../model/artist.js'); const artistRouter = new Router(); + +artistRouter.post('/api/artist', jsonParser, function(req, res, next) { + debug('POST: /api/artist'); + + Artist.createArtist(req.body) + .then( artist => res.json(artist)) + .catch( err => next(err)); +}); + +artistRouter.get('/api/artist/:id', function(req, res, next) { + debug('GET: /api/artist/:id'); + + Artist.fetchArtist(req.params.id) + .then( artist => res.json(artist)) + .catch( err => next(err)); +}); + +artistRouter.get('/api/artist', function(req, res, next) { + debug('GET: api/artist'); + + Artist.fetchIDs() + .then( ids => res.json(ids)) + .catch(next); +}); + +artistRouter.put('/api/artist', jsonParser, function(req, res, next) { + debug('PUT: /api/artist'); + + Artist.updateArtist(req.query.id, req.body) + .then( artist => res.json(artist)) + .catch(next); +}); + +module.exports = artistRouter; From 500488c506821fbec5f565866253372627ae7d9a Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Tue, 20 Dec 2016 17:39:55 -0800 Subject: [PATCH 08/11] all server dependencies required in --- server.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 3db4210..6d8c978 100644 --- a/server.js +++ b/server.js @@ -2,13 +2,19 @@ const morgan = require('morgan'); const express = require('express'); -const debug = require('debug')('note:server'); +const createError = require('http-errors'); +const cors = require('./lib/cors-middleware.js'); +const errors = require('./lib/err-middleware.js'); +const debug = require('debug')('artist:server'); const artistRouter = require('./route/artist-router.js'); const PORT = 3000; const app = express(); app.use(morgan('dev')); +app.use(cors); +app.use(artistRouter); +app.use(errors); app.listen(PORT, () => { console.log(`server live on: ${PORT}`); From b76006051d09910e6b990520de3bbe1bf7360ddd Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Tue, 20 Dec 2016 18:32:15 -0800 Subject: [PATCH 09/11] renamed model file, route-tests complete --- .../cb000020-c71e-11e6-b55a-156f3ac3297a.json | 1 + model/{artist.js => music-artists.js} | 4 +- route/artist-router.js | 2 +- test/artist-route-test.js | 119 ++++++++++++++++++ 4 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 data/artist/cb000020-c71e-11e6-b55a-156f3ac3297a.json rename model/{artist.js => music-artists.js} (93%) create mode 100644 test/artist-route-test.js diff --git a/data/artist/cb000020-c71e-11e6-b55a-156f3ac3297a.json b/data/artist/cb000020-c71e-11e6-b55a-156f3ac3297a.json new file mode 100644 index 0000000..855ac3a --- /dev/null +++ b/data/artist/cb000020-c71e-11e6-b55a-156f3ac3297a.json @@ -0,0 +1 @@ +{"id":"cb000020-c71e-11e6-b55a-156f3ac3297a","name":"Blink-182","genre":"Punk"} \ No newline at end of file diff --git a/model/artist.js b/model/music-artists.js similarity index 93% rename from model/artist.js rename to model/music-artists.js index 18b8e0b..b2e69ae 100644 --- a/model/artist.js +++ b/model/music-artists.js @@ -2,7 +2,7 @@ const uuid = require('node-uuid'); const createError = require('http-errors'); -const debug = require('debug')('artist:artist'); +const debug = require('debug')('music-artists:music-artists'); const storage = require('../lib/storage.js'); const Artist = module.exports = function(name, genre) { @@ -11,7 +11,7 @@ const Artist = module.exports = function(name, genre) { if(!name) throw createError(400, 'expected name'); if(!genre) throw createError(400, 'expected genre'); - this.id = uuid.v2(); + this.id = uuid.v1(); this.name = name; this.genre = genre; diff --git a/route/artist-router.js b/route/artist-router.js index 8d11e16..af7c712 100644 --- a/route/artist-router.js +++ b/route/artist-router.js @@ -3,7 +3,7 @@ const Router = require('express').Router; const jsonParser = require('body-parser').json(); const debug = require('debug')('artist:artist-router.js'); -const Artist = require('../model/artist.js'); +const Artist = require('../model/music-artists.js'); const artistRouter = new Router(); artistRouter.post('/api/artist', jsonParser, function(req, res, next) { diff --git a/test/artist-route-test.js b/test/artist-route-test.js new file mode 100644 index 0000000..b48a29f --- /dev/null +++ b/test/artist-route-test.js @@ -0,0 +1,119 @@ +'use strict'; + +const expect = require('chai').expect; +const request = require('superagent'); +const Artist = require('../model/music-artists.js'); +const url = 'http://localhost:3000'; + +require('../server.js'); + +const exampleArtist = { + name: 'test name', + genre: 'test genre' +}; + +describe('Artist Routes', function() { + + describe('GET: /api/artist', function() { + describe('with a vaild id', function() { + before( done => { + Artist.createArtist(exampleArtist) + .then(artist => { + this.tempArtist = artist; + done(); + }) + .catch( err => done(err)); + }); + + after( done => { + Artist.deleteArtist(this.tempArtist.id) + .then( () => done()) + .catch( err => done(err)); + }); + + it('should return an artist', done => { + request.get(`${url}/api/artist/${this.tempArtist.id}`) + .end((err, res) => { + if (err) return done(err); + expect(res.status).to.equal(200); + expect(res.body.id).to.equal(this.tempArtist.id); + expect(res.body.name).to.equal(this.tempArtist.name); + expect(res.body.content).to.equal(this.tempArtist.content); + done(); + }); + }); + + describe('with an invalid id', function() { + it('should respond with 404 status code', done => { + request.get(`${url}/api/artist/123456789`) + .end((err, res) => { + expect(res.status).to.equal(404); + done(); + }); + }); + }); + }); + }); + + describe('POST: /api/artist', function() { + describe('with a valid body', function() { + after( done => { + if (this.tempArtist) { + Artist.deleteArtist(this.tempArtist.id) + .then( () => done()) + .catch( err => done(err)); + } + }); + + it('should return an artist', done => { + request.post(`${url}/api/artist`) + .send(exampleArtist) + .end((err, res) => { + if (err) return done(err); + expect(res.status).to.equal(200); + expect(res.body.name).to.equal(exampleArtist.name); + expect(res.body.content).to.equal(exampleArtist.content); + this.tempNote = res.body; + done(); + }); + }); + }); + }); + + describe('PUT: /api/artist', function() { + describe('with a valid id & body', function() { + before( done => { + Artist.createArtist(exampleArtist) + .then( artist => { + this.tempArtist = artist; + done(); + }) + .catch( err => done(err)); + }); + + after( done => { + if(this.tempArtist) { + Artist.deleteArtist(this.tempArtist.id) + .then( () => done()) + .catch(done); + } + }); + + it('should return an artist', done => { + let updateArtist = {name: 'new name', genre: 'new genre'}; + request.put(`${url}/api/artist?id=${this.tempArtist.id}`) + .send(updateArtist) + .end((err, res) => { + if (err) return done(err); + expect(res.status).to.equal(200); + expect(res.body.id).to.equal(this.tempArtist.id); + for (var prop in updateArtist) { + expect(res.body[prop]).to.equal(updateArtist[prop]); + } + done(); + }); + }); + }); + }); + +}); From fde5c974094e370a36a110d496503f2c67b9e685 Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Wed, 21 Dec 2016 10:14:01 -0800 Subject: [PATCH 10/11] README complete, all tests pass --- README.md | 84 +++++++++++++++++++ .../ceb2b430-c7a8-11e6-8966-5197e7604b92.json | 1 + 2 files changed, 85 insertions(+) create mode 100644 README.md create mode 100644 data/artist/ceb2b430-c7a8-11e6-8966-5197e7604b92.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..61f02dc --- /dev/null +++ b/README.md @@ -0,0 +1,84 @@ +# Express Single Resource API with middleware + +This express single resource API allows a user to make GET, PUT, and POST requests to the Artist object. The user can POST a new Artist name and genre, receive an id, and can get the Artist by that id. + +### Set-Up + +In your Terminal + +```sh +$ git clone +$ cd 12-express_middleware +$ npm i +``` +This will install the proper dependencies. You should receive the following in your package.json file: + +```sh +"dependencies": { + "bluebird": "^3.4.6", + "body-parser": "^1.15.2", + "chai": "^3.5.0", + "debug": "^2.4.5", + "express": "^4.14.0", + "http-errors": "^1.5.1", + "mocha": "^3.2.0", + "morgan": "^1.7.0", + "node-uuid": "^1.4.7", + "superagent": "^3.3.1" +} +``` + +Run `node server.js` or to start your server. Or run `npm run start` to include debug while starting your server. You will receive a response of 'server live on PORT: ``' + + +### Use + +Making a POST request +* Run `http POST localhost:/api/artist name='' genre=''` +* This will update the Artist object to show `name:` `genre:` and `id:` +* You will also receive a status code of 200. + +Example: +```sh +HTTP/1.1 200 OK +Access-Control-Allow-Headers: * +Access-Control-Allow-Origin: * +Connection: keep-alive +Content-Length: 79 +Content-Type: application/json; charset=utf-8 +Date: Wed, 21 Dec 2016 01:42:55 GMT +ETag: W/"4f-XrtcY5ELsfZ6vIlKoUtB+Q" +X-Powered-By: Express + +{ + "genre": "Punk", + "id": "cb000020-c71e-11e6-b55a-156f3ac3297a", + "name": "Blink-182" +} +``` + +Making a GET request +* Run `http localhost:/api/artist?id=` +* You must copy and paste the id from the post request. +* You will also receive a status code of 200. + +Example: +```sh +HTTP/1.1 200 OK +Access-Control-Allow-Headers: * +Access-Control-Allow-Origin: * +Connection: keep-alive +Content-Length: 40 +Content-Type: application/json; charset=utf-8 +Date: Wed, 21 Dec 2016 01:43:28 GMT +ETag: W/"28-ivjiv1YIQTFvK7z9Yn5eIA" +X-Powered-By: Express + +[ + "cb000020-c71e-11e6-b55a-156f3ac3297a" +] +``` + +* If you run `http localhost:/api/artist` you should receive a 400 status code, and a message of 'bad request' + +* If you run `http POST localhost:/api/artist` you should receive a 400 status code, and a message of 'bad request' diff --git a/data/artist/ceb2b430-c7a8-11e6-8966-5197e7604b92.json b/data/artist/ceb2b430-c7a8-11e6-8966-5197e7604b92.json new file mode 100644 index 0000000..a3890e2 --- /dev/null +++ b/data/artist/ceb2b430-c7a8-11e6-8966-5197e7604b92.json @@ -0,0 +1 @@ +{"id":"ceb2b430-c7a8-11e6-8966-5197e7604b92","name":"U2","genre":"easy listening"} \ No newline at end of file From 0a518e130f16e6e4c2458d583d2ab76a4ed19fda Mon Sep 17 00:00:00 2001 From: Daniel Becker Date: Wed, 21 Dec 2016 10:51:40 -0800 Subject: [PATCH 11/11] fixed typo --- test/artist-route-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/artist-route-test.js b/test/artist-route-test.js index b48a29f..ad309dd 100644 --- a/test/artist-route-test.js +++ b/test/artist-route-test.js @@ -73,7 +73,7 @@ describe('Artist Routes', function() { expect(res.status).to.equal(200); expect(res.body.name).to.equal(exampleArtist.name); expect(res.body.content).to.equal(exampleArtist.content); - this.tempNote = res.body; + this.tempArtist = res.body; done(); }); });