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
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#2f7c47",
"activityBar.background": "#2f7c47",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#422c74",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#2f7c47",
"statusBar.background": "#215732",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#2f7c47",
"statusBarItem.remoteBackground": "#215732",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#215732",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#21573299",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#215732"
}
45 changes: 39 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
# Project API
# Backend for the Happy Thoughts project

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.
## Check out demo here:

## Getting started
[Backend part demo on Render](https://get-thoughts-out-api.onrender.com)
OBS! It is deployed on Render, and API goes to sleep after 50 sec on inactivity. Allow some time for it to respond for the first time.

Install dependencies with `npm install`, then start the server by running `npm run dev`
[Full Happy Thoughts project](https://happy-thoughts-byjd.netlify.app/)(no sign-up needed to see the feed, but if you want to submit your thoughts, please register a user first)

## View it live
## Overview:

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.
Happy Thoughts Tiny API
A RESTful API for sharing, managing, and reacting to short happy thoughts. Built with Node.js, Express, and MongoDB/Mongoose — with full authentication support.
OBS! It is deployed on Render, and API goes to sleep after 50 sec on inactivity. Allow some time for it to respond for the first time.

### Features

- Browse thoughts — fetch all thoughts with filtering and sorting options (by date, likes, or category)
- Single thought lookup — retrieve one thought by ID
- Like a thought — increment the heart count on any thought
- Full CRUD — authenticated users can create, update, and delete their own thoughts
- Auth — sign up and log in with encrypted passwords (bcrypt) and token-based authentication
- Input validation — meaningful error responses for invalid or duplicate data (e.g. unique emails enforced)
- API docs — auto-generated endpoint listing via Express List Endpoints

> Frontend part lives in [this repo](https://github.com/Demijuls/js-project-happy-thoughts).

###### Created as a part full-stack programm in TechniGo bootcamp.

### API includes:

- RESTful APIs
- MongoDB for database + data modeling in mongoose
- Authentication with user token
- Endpoints GET, POST, PUT, DELETE
- Filtering and sorting

### Tech Stack

Node.js + Express
MongoDB + Mongoose
bcrypt for password hashing
JWT for authentication
Deployed on Render
18 changes: 9 additions & 9 deletions data.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[
{
"_id": "682bab8c12155b00101732ce",
{
"_id": "682bab8c12155b00101732cb",
"message": "Berlin baby",
"hearts": 37,
"createdAt": "2025-05-19T22:07:08.999Z",
"__v": 0
},
{
"_id": "682e53cc4fddf50010bbe739",
"_id": "682e53cc4fddf50010bbe739",
"message": "My family!",
"hearts": 0,
"createdAt": "2025-05-22T22:29:32.232Z",
Expand All @@ -17,15 +17,15 @@
"_id": "682e4f844fddf50010bbe738",
"message": "The smell of coffee in the morning....",
"hearts": 23,
"createdAt": "2025-05-22T22:11:16.075Z",
"createdAt": "2024-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
"__v": 0
},
{
"_id": "682e45804fddf50010bbe736",
Expand Down Expand Up @@ -53,7 +53,7 @@
"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
"__v": 0
},
{
"_id": "682cebbe17487d0010a298b5",
Expand All @@ -74,7 +74,7 @@
"message": "Summer is coming...",
"hearts": 2,
"createdAt": "2025-05-20T15:03:22.379Z",
"__v": 0
"__v": 0
},
{
"_id": "682c706c951f7a0017130024",
Expand Down Expand Up @@ -113,9 +113,9 @@
},
{
"_id": "682bab8c12155b00101732ce",
"message": "Berlin baby",
"message": "London baby",
"hearts": 37,
"createdAt": "2025-05-19T22:07:08.999Z",
"__v": 0
}
]
]
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@
"description": "Project API",
"scripts": {
"start": "babel-node server.js",
"dev": "nodemon server.js --exec babel-node"
"dev": "nodemon server.js --exec babel-node",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@babel/core": "^7.17.9",
"@babel/node": "^7.16.8",
"@babel/preset-env": "^7.16.11",
"bcrypt": "^6.0.0",
"bcrypt-nodejs": "^0.0.3",
"cors": "^2.8.5",
"express": "^4.17.3",
"express-list-endpoints": "^7.1.1",
"mongodb": "^7.0.0",
"mongoose": "^9.1.5",
"nodemon": "^3.0.1"
},
"devDependencies": {
"@types/bcrypt-nodejs": "^0.0.31"
}
}
Loading