Skip to content

Commit 2c02184

Browse files
committed
Implement recycle bin functionality for notes: Add UI tabs for notes and trash, update API endpoints for managing trashed notes, and enhance note repository methods for soft deletion and restoration.
1 parent 902c1bc commit 2c02184

22 files changed

Lines changed: 1728 additions & 302 deletions

DOCUMENTATION.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,52 @@ For API endpoints, we use a special pattern:
112112
```javascript
113113
/**
114114
* @name GET /notes
115-
* @description Retrieve all notes from the database
115+
* @description Retrieve all active notes from the database
116116
* @route GET /
117-
* @returns {Object[]} 200 - Array of note objects
117+
* @returns {Object[]} 200 - Array of active note objects
118118
* @returns {Object} 500 - Error response
119119
* @example
120120
* // Response format:
121121
* [
122122
* {
123123
* "id": "note_123",
124124
* "title": "Sample Note",
125-
* "content": "This is a sample note content"
125+
* "content": "This is a sample note content",
126+
* "status": "active",
127+
* "deletedAt": null,
128+
* "createdAt": "2023-01-01T00:00:00.000Z",
129+
* "updatedAt": "2023-01-02T00:00:00.000Z"
126130
* }
127131
* ]
128132
*/
129133
```
130134

135+
### Trash Functionality API Documentation
136+
The application now includes comprehensive trash functionality with the following endpoints:
137+
138+
```javascript
139+
/**
140+
* @name GET /notes/trash
141+
* @description Retrieve all deleted notes
142+
* @route GET /trash
143+
* @returns {Object[]} 200 - Array of deleted note objects
144+
*/
145+
146+
/**
147+
* @name POST /notes/:id/restore
148+
* @description Restore a note from trash
149+
* @route POST /:id/restore
150+
* @returns {void} 204 - No content (successful restoration)
151+
*/
152+
153+
/**
154+
* @name DELETE /notes/:id/permanent
155+
* @description Permanently delete a note
156+
* @route DELETE /:id/permanent
157+
* @returns {void} 204 - No content (successful permanent deletion)
158+
*/
159+
```
160+
131161
This creates comprehensive API documentation in the Global section.
132162

133163
## Maintaining Documentation

README.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ A RESTful API for managing text notes, built with Node.js, Express, and NoSQL da
1717
## Features
1818

1919
- Create, read, update, and delete text notes
20+
- **Trash functionality** - Move notes to trash instead of immediate deletion
21+
- **Restore notes** from trash or permanently delete them
2022
- RESTful API design
21-
- Simple and intuitive web UI
23+
- Simple and intuitive web UI with tabs for Notes and Trash
2224
- Database-agnostic architecture
2325
- Multiple database implementations (CouchDB, MongoDB)
2426
- Environment-based configuration
@@ -151,6 +153,22 @@ Each Docker Compose setup includes:
151153
- **Data persistence**: Named volumes for database data
152154
- **Network isolation**: Services communicate through a private network
153155

156+
### Local Testing
157+
158+
Run the following command to execute tests and get a coverage report:
159+
160+
```shell
161+
npm run test:coverage
162+
```
163+
164+
Then open report file from `coverage/lcov-report/index.html`.
165+
166+
Or, alternatively, use an existing custom script:
167+
168+
```shell
169+
npm run test:coverage:open
170+
```
171+
154172
### Automated Testing
155173

156174
#### Local Testing Script
@@ -232,11 +250,16 @@ Once the server is running, you can:
232250

233251
## API Endpoints
234252

235-
### Get all notes
253+
### Get all active notes
236254
```
237255
GET /api/notes
238256
```
239257

258+
### Get all deleted notes
259+
```
260+
GET /api/notes/trash
261+
```
262+
240263
### Get a note by ID
241264
```
242265
GET /api/notes/:id
@@ -264,11 +287,21 @@ Content-Type: application/json
264287
}
265288
```
266289

267-
### Delete a note
290+
### Move a note to trash (soft delete)
268291
```
269292
DELETE /api/notes/:id
270293
```
271294

295+
### Restore a note from trash
296+
```
297+
POST /api/notes/:id/restore
298+
```
299+
300+
### Permanently delete a note
301+
```
302+
DELETE /api/notes/:id/permanent
303+
```
304+
272305
## Health Check
273306

274307
```
@@ -285,10 +318,15 @@ http://localhost:3000/
285318

286319
### UI Features
287320

288-
- View all notes in a responsive grid layout
321+
- **Tab Navigation**: Switch between "Notes" and "Trash" views
322+
- **Notes View**: View all active notes in a responsive grid layout
323+
- **Recycle Bin View**: View deleted notes with restore/permanently delete options
289324
- Create new notes with a modal form
290325
- Edit existing notes
291-
- Delete notes with confirmation
326+
- **Trash Operations**:
327+
- Move notes to trash (soft delete) with confirmation
328+
- Restore notes from trash back to active status
329+
- Permanently delete notes from trash (with strong confirmation)
292330
- Responsive design that works on desktop and mobile devices
293331

294332
The UI is built with vanilla JavaScript, HTML, and CSS, with no external dependencies. It communicates with the API endpoints described above.

0 commit comments

Comments
 (0)