Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
# Project API
# Happy Thoughts API

This project includes the packages and babel setup for an express server, and is just meant to make things a little simpler to get up and running with.
Hi there! I built this Happy Thoughts API as part of my Technigo JavaScript Bootcamp 2025 journey. This is a RESTful API built with Express.js and MongoDB that lets users create, read, update, and delete happy thoughts, as well as like them.

## Getting started
## Key Features

Install dependencies with `npm install`, then start the server by running `npm run dev`
- Full CRUD operations: Create, Read, Update, and Delete thoughts
- Like (heart) a thought
- Data stored in MongoDB with Mongoose models
- Input validation (message must be 5-140 characters)
- Error handling with proper HTTP status codes
- Database seeding with sample data

## Tech Stack

- Node.js
- Express.js
- MongoDB + Mongoose
- dotenv

## API Endpoints

| Method | Path | Description |
|--------|------|-------------|
| GET | `/` | API documentation |
| GET | `/thoughts` | Get all thoughts (newest first, limit 20) |
| GET | `/thoughts/:id` | Get a single thought by ID |
| POST | `/thoughts` | Create a new thought |
| PATCH | `/thoughts/:id` | Update a thought |
| DELETE | `/thoughts/:id` | Delete a thought |
| POST | `/thoughts/:id/like` | Like a thought (+1 heart) |

## Getting Started

1. Install dependencies: `npm install`
2. Create a `.env` file with your MongoDB connection string:
```
MONGO_URL=mongodb+srv://your-connection-string
RESET_DB=true
```
3. Start the server: `npm run dev`
4. After seeding, set `RESET_DB=false` in `.env`

## View it live

Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about.
Backend: _add your Render link here_
File renamed without changes.
123 changes: 123 additions & 0 deletions backend/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"thoughts": [
{
"_id": "682bab8c12155b00101732ce",
"message": "Berlin baby",
"hearts": 37,
"createdAt": "2025-05-19T22:07:08.999Z",
"__v": 0
},
{
"_id": "682e53cc4fddf50010bbe739",
"message": "My family!",
"hearts": 0,
"createdAt": "2025-05-22T22:29:32.232Z",
"__v": 0
},
{
"_id": "682e4f844fddf50010bbe738",
"message": "The smell of coffee in the morning....",
"hearts": 23,
"createdAt": "2025-05-22T22:11:16.075Z",
"__v": 0
},
{
"_id": "682e48bf4fddf50010bbe737",
"message": "Newly washed bedlinen, kids that sleeps through the night.. FINGERS CROSSED 🤞🏼\n",
"hearts": 6,
"createdAt": "2025-05-21T21:42:23.862Z",
"__v": 0
},
{
"_id": "682e45804fddf50010bbe736",
"message": "I am happy that I feel healthy and have energy again",
"hearts": 13,
"createdAt": "2025-05-21T21:28:32.196Z",
"__v": 0
},
{
"_id": "682e23fecf615800105107aa",
"message": "cold beer",
"hearts": 2,
"createdAt": "2025-05-21T19:05:34.113Z",
"__v": 0
},
{
"_id": "682e22aecf615800105107a9",
"message": "My friend is visiting this weekend! <3",
"hearts": 6,
"createdAt": "2025-05-21T18:59:58.121Z",
"__v": 0
},
{
"_id": "682cec1b17487d0010a298b6",
"message": "A god joke: \nWhy did the scarecrow win an award?\nBecause he was outstanding in his field!",
"hearts": 12,
"createdAt": "2025-05-20T20:54:51.082Z",
"__v": 0
},
{
"_id": "682cebbe17487d0010a298b5",
"message": "Tacos and tequila🌮🍹",
"hearts": 2,
"createdAt": "2025-05-19T20:53:18.899Z",
"__v": 0
},
{
"_id": "682ceb5617487d0010a298b4",
"message": "Netflix and late night ice-cream🍦",
"hearts": 1,
"createdAt": "2025-05-18T20:51:34.494Z",
"__v": 0
},
{
"_id": "682c99ba3bff2d0010f5d44e",
"message": "Summer is coming...",
"hearts": 2,
"createdAt": "2025-05-20T15:03:22.379Z",
"__v": 0
},
{
"_id": "682c706c951f7a0017130024",
"message": "Exercise? I thought you said extra fries! 🍟😂",
"hearts": 14,
"createdAt": "2025-05-20T12:07:08.185Z",
"__v": 0
},
{
"_id": "682c6fe1951f7a0017130023",
"message": "I’m on a seafood diet. I see food, and I eat it.",
"hearts": 4,
"createdAt": "2025-05-20T12:04:49.978Z",
"__v": 0
},
{
"_id": "682c6f0e951f7a0017130022",
"message": "Cute monkeys🐒",
"hearts": 2,
"createdAt": "2025-05-20T12:01:18.308Z",
"__v": 0
},
{
"_id": "682c6e65951f7a0017130021",
"message": "The weather is nice!",
"hearts": 0,
"createdAt": "2025-05-20T11:58:29.662Z",
"__v": 0
},
{
"_id": "682bfdb4270ca300105af221",
"message": "good vibes and good things",
"hearts": 3,
"createdAt": "2025-05-20T03:57:40.322Z",
"__v": 0
},
{
"_id": "682bab8c12155b00101732ce",
"message": "Berlin baby",
"hearts": 37,
"createdAt": "2025-05-19T22:07:08.999Z",
"__v": 0
}
]
}
32 changes: 32 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "kausar",
"version": "1.0.0",
"description": "Project API",
"homepage": "https://github.com/KausarShangareeva/js-project-api-express.js#readme",
"bugs": {
"url": "https://github.com/KausarShangareeva/js-project-api-express.js/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/KausarShangareeva/js-project-api-express.js.git"
},
"license": "ISC",
"author": "",
"type": "commonjs",
"main": "server.js",
"scripts": {
"start": "babel-node server.js",
"dev": "nodemon server.js --exec babel-node"
},
"dependencies": {
"@babel/core": "^7.28.6",
"@babel/node": "^7.28.6",
"@babel/preset-env": "^7.28.6",
"bcrypt": "^6.0.0",
"cors": "^2.8.6",
"dotenv": "^17.2.4",
"express": "^4.17.3",
"mongoose": "^9.1.5",
"nodemon": "^3.1.11"
}
}
Loading