- Node.js 18.16 LTS
- MySQL 5.7
Functions implemented:
- Insert item(s) in ToDo list
- Delete item(s) in ToDo list
- Delete a ToDo list
- Create a new ToDo list
- Mark an item as completed
- Add a reminder for the list (not for the item)
| Description | Method | URL pattern | Local test | Deployed test |
|---|---|---|---|---|
| Simple homepage | GET | http://localhost:3000 or http://localhost:3000/ |
http://localhost:3000/ or http://localhost:3000/ | https://todoapptest.fly.dev or https://todoapptest.fly.dev/ |
| Get user's todo lists | GET | http://localhost:3000/user/:userId/lists |
http://localhost:3000/user/1/lists | https://todoapptest.fly.dev/user/1/lists |
| Get user's todo list by ID | GET | http://localhost:3000/user/:userId/lists/:listId |
http://localhost:3000/user/1/lists/1 | https://todoapptest.fly.dev/user/1/lists/1 |
| Create a todo list | POST | http://localhost:3000/user/:userId/lists |
http://localhost:3000/user/1/lists | https://todoapptest.fly.dev/user/1/lists |
| Delete a todo list | DELETE | http://localhost:3000/user/:userId/lists/:listId |
http://localhost:3000/user/1/lists/1 | https://todoapptest.fly.dev/user/1/lists/2 |
| Add reminder to the list | POST | http://localhost:3000/user/:userId/lists/:listId/reminders |
http://localhost:3000/user/1/lists/1/reminders | https://todoapptest.fly.dev/user/1/lists/3/reminders |
| Insert item(s) in todo list | POST | http://localhost:3000/user/:userId/lists/:listId/items |
http://localhost:3000/user/1/lists/1/items | https://todoapptest.fly.dev/user/1/lists/4/items |
| Get item(s) from a todo list | GET | http://localhost:3000/user/:userId/lists/:listId/items |
http://localhost:3000/user/1/lists/1/items | https://todoapptest.fly.dev/user/1/lists/4/items |
| Delete item(s) from todo list | DELETE | http://localhost:3000/user/:userId/lists/:listId/items/:itemId |
http://localhost:3000/user/1/lists/1/items/1 | https://todoapptest.fly.dev/user/1/lists/1/items/18/ |
| Mark item as completed | PATCH | http://localhost:3000/user/:userId/lists/:listId/items/:itemId |
http://localhost:3000/user/1/lists/1/items/1 | https://todoapptest.fly.dev/user/1/lists/items/2 |
- Clone repo
- Navigate to
Databases/Week3/todo-app - Run
npm installto install dependencies - Make a copy of
.env.sampleand rename it as.env. - Inside
.env:- put your database user name into MYSQL_USER and
- put your database user password into MYSQL_PASSWORD and
- Import
todo_app.sqldatabase or just run sql queries in mysql console to create a db. - Make sure your database is called
todo_app. - To start server run any of the listed commands
npm startnode index.jsnodemon run
- Open in browser
localhost:3000or127.0.0.1:3000
-
Check urls from endpoints table and response results in browser devtools response for get requests.
-
Use Postman or Thunder Client VS Code extension to check endpoints all requests implemented:
-
Link to my prepared postman requests for both
localhostandfly.iocreated to test this app:
Don't forget to install postman agent.
- To test requests for different lists, users, items in Postman got to
Params => Path Variablesand change value of tested parameter:- userId - 1 or 2 (only 2 users in db now)
- listId - 1...4;
- itemId - 1...35.
- Database: https://todoapp-mysql-db.fly.dev/ (private service, available only from fly.io account)
- Database setup repo: https://github.com/yulsmir/todo-app-mysqldb-fly.io
- App: https://todoapptest.fly.dev/