stenlisuryadinata / project-happy-thoughts-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Project Happy Thoughts API

This project is a backend API for the "Happy Thoughts" application, which allows users to post, view, like, and delete happy thoughts. The API is built using Node.js, Express, and MongoDB.

The Problem

The goal of this project is to create a robust and scalable API that supports various operations related to thoughts. The API defines a Thought model with specific validations for the message, hearts, and createdAt properties.

Approach and Technologies Used

Node.js

Used as the runtime environment for the server.

Express

Chosen as the web framework for handling HTTP requests and responses.

MongoDB

Utilized as the database for storing thoughts.

Mongoose

An ODM library for MongoDB, used to model thoughts and interact with the database.

dotenv

Configured to handle environment variables, such as the MongoDB connection string.

Express List Endpoints

Integrated to automatically generate API documentation.

The project follows RESTful conventions with endpoints for retrieving all thoughts, creating a new thought, retrieving a specific thought by ID, updating hearts on a thought, and deleting a thought.

How I Approached the Problem

Model Definition

Defined a Thought model with proper validations for the message, hearts, and createdAt properties.

Express Routes

Implemented routes for CRUD operations on thoughts using Express.

MongoDB Connection

Established a connection to MongoDB, allowing the API to persistently store and retrieve thoughts.

Error Handling

Implemented error handling for various scenarios, providing meaningful responses.

Deployment

Deployed the API to MongoDB Atlas to make it accessible online.

If I Had More Time

Given more time, I would consider the following enhancements:

User Authentication

Implement user authentication to allow users to have personalized experiences.

Pagination

Add support for paginating through large sets of thoughts.

Testing

Implement comprehensive testing for the API using tools like Mocha and Chai.

Logging

Integrate logging to capture and analyze application events.

The API is live and can be accessed at Project Happy Thoughts API.

Feel free to explore the various endpoints and interact with the API using your preferred API client or tools like Postman.

Feel free to explore the various endpoints and interact with the API using your preferred API client or tools like Postman.

About


Languages

Language:JavaScript 100.0%