Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Updated server
Browse files Browse the repository at this point in the history
  • Loading branch information
veronikabenkeser committed Mar 30, 2018
1 parent 47501be commit 21fc7c9
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 29 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ You'll build the front end of the Contacts app throughout the course. Because th
Getting the server running on your local machine takes only a few steps:

1. clone the project - `git clone https://github.com/udacity/reactnd-contacts-server.git`
2. install its dependencies - `npm install`
3. start the server - `node server.js`
2. `cd reactnd-contacts-server`
3. install its dependencies - `npm install`
4. start the server - `node server.js`

## Contributing

Expand Down
18 changes: 9 additions & 9 deletions contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ const db = {}
const defaultData = {
contacts: [
{
id: 'ryan',
name: 'Ryan Florence',
email: 'ryan@reacttraining.com',
avatarURL: config.origin + '/ryan.jpg'
id: 'richard',
name: 'Richard Kalehoff',
handle: '@richardkalehoff',
avatarURL: config.origin + '/city.jpg'
},
{
id: 'michael',
name: 'Michael Jackson',
email: 'michael@reacttraining.com',
avatarURL: config.origin + '/michael.jpg'
id: 'karen',
name: 'Karen Isgrigg',
handle: '@karen_isgrigg',
avatarURL: config.origin + '/trees.jpg'
},
{
id: 'tyler',
name: 'Tyler McGinnis',
email: 'tyler@reacttraining.com',
handle: '@tylermcginnis',
avatarURL: config.origin + '/tyler.jpg'
}
]
Expand Down
137 changes: 123 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added public/city.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/michael.jpg
Binary file not shown.
Binary file removed public/ryan.jpg
Binary file not shown.
Binary file added public/trees.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ app.get('/', (req, res) => {
GET /contacts
DELETE /contacts/:id
POST /contacts { name, email, avatarURL }
POST /contacts { name, handle, avatarURL }
</pre>
`

Expand Down Expand Up @@ -51,13 +51,13 @@ app.delete('/contacts/:id', (req, res) => {
})

app.post('/contacts', bodyParser.json(), (req, res) => {
const { name, email } = req.body
const { name, handle } = req.body

if (name && email) {
if (name && handle) {
res.send(contacts.add(req.token, req.body))
} else {
res.status(403).send({
error: 'Please provide both a name and email address'
error: 'Please provide both a name and a handle'
})
}
})
Expand Down

0 comments on commit 21fc7c9

Please sign in to comment.