-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature #159068545] Add /DELETE/:id entries endpoint
- Loading branch information
1 parent
cfcce8f
commit bebc0c4
Showing
5 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,71 @@ | ||
[![Build Status](https://travis-ci.org/olusoladavid/my-diary.svg?branch=ft-rest-api-endpoints-159069640)](https://travis-ci.org/olusoladavid/my-diary) | ||
[![Coverage Status](https://coveralls.io/repos/github/olusoladavid/my-diary/badge.svg?branch=ft-rest-api-endpoints-159069640)](https://coveralls.io/github/olusoladavid/my-diary?branch=ft-rest-api-endpoints-159069640) | ||
[![Coverage Status](https://coveralls.io/repos/github/olusoladavid/my-diary/badge.svg?branch=develop)](https://coveralls.io/github/olusoladavid/my-diary?branch=ft-rest-api-endpoints-159069640) | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/28ee352fbbd498a8cafd/maintainability)](https://codeclimate.com/github/olusoladavid/my-diary/maintainability) | ||
|
||
# my-diary | ||
|
||
MyDiary is an online journal where users can pen down their thoughts and feelings | ||
|
||
## Required Features | ||
|
||
- Users can create an account and log in. | ||
- User can view all entries to their diary. | ||
- Users can view the contents of a diary entry. | ||
- Users can add or modify an entry. | ||
- Users can delete an entry | ||
|
||
## Additional Features | ||
|
||
- Users can set and get daily notifications that prompt them to add an entry to their diary | ||
|
||
## Technologies | ||
|
||
- Nodejs | ||
- Express | ||
- Mocha (with Chai as assertion library) | ||
- Babel (ES6+ to ES5 transpilation) | ||
- ESLint (with Airbnb style guide) | ||
|
||
## API Endpoints | ||
|
||
| Endpoint | Functionality | | ||
| --------------------------- | -------------------- | | ||
| GET `/entries` | Fetch all entries | | ||
| GET `/entries/<entryId>` | Fetch a single entry | | ||
| POST `/entries` | Create an entry | | ||
| PUT `/entries/<entryId>` | Modify an entry | | ||
| DELETE `/entries/<entryId>` | Delete an entry | | ||
|
||
## Build Setup | ||
|
||
``` | ||
clone repo and cd into directory | ||
git clone https://github.com/olusoladavid/my-diary.git | ||
``` | ||
|
||
``` | ||
# install dependencies | ||
npm install | ||
#serve in development environment | ||
npm run dev | ||
# build for production | ||
npm run build | ||
``` | ||
|
||
## Testing | ||
|
||
``` | ||
# Run test cases | ||
npm test | ||
``` | ||
|
||
API Endpoint: https://my-diary-api.herokuapp.com/api/v1 | ||
|
||
UI Template: https://olusoladavid.github.io/my-diary/UI/ | ||
|
||
## License | ||
|
||
- MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import entries from '../db/entries'; | ||
|
||
const deleteEntry = (req, res) => { | ||
const indexOfFound = entries.findIndex(entry => entry.id === Number(req.params.id)); | ||
if (indexOfFound > -1) { | ||
entries.splice(indexOfFound, 1); | ||
res.status(204).json(); | ||
} else { | ||
res.status(404).json({ errors: [{ msg: 'Entry does not exist' }] }); | ||
} | ||
}; | ||
|
||
export default deleteEntry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters