This project's goal was to build an API which includes both GET request endpoints to return data and POST endpoints to create data. For the front end I revisited my previous project Happy Thoughts a twitter like app where you can see other people's happy thoughts, post your own and give a โค๏ธ to an existing one. You can see the live version here, feel free to leave me some happy thoughts! Happy Thoughts
- This Express API consists of a MongoDB stored in Atlas and deployed to Heroku
- My first step in this project was to create the mongoose model for the Thought, the model schema consists of three main components: message, hearts and createdAt, with several validation rules embedded, i.e. required.
- Used try and catch in all endpoints for error handling.
Root: Welcome page
Displays the latest 20 thoughts, sorted by createdAt to show the most recent thoughts first.
Endpoint to post and save a new thought to the database. It expects a JSON body with the thought message, like this: { "message": "Happy New Year!" }
This endpoint doesn't require a JSON body. Given a valid thought id in the URL, the API should find that thought, and update its hearts property to add one heart.
- MongoDB
- Mongoose
- Node.js
- Express