Skip to content

Vera-Sjunnesson/project-happy-thoughts-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Happy Thoughts API

This is the API for my Happy Thoughts project, a version of Twitter which only allows happy thoughts!

The problem

To set up a database on MongoDB and to build an API, using mongoose, to POST to and GET data from the database and then fetch the data in the frontend Happy thoughts project

Functionality

The user can:

  • Post thoughts
  • Add their name and a category to their post (optional)
  • View their own and other users thoughts in chronological order
  • Like thoughts
  • See when thoughts where created, by whom and what category the thought is
  • See how many times they've liked something

Technologies & Tools

  • MongoDB
  • Node.js
  • Mongoose
  • Express.js
  • CORS
  • Express List Endpoints
  • Postman

Endpoints

"/" - Defining the route with a welcome message and links

"/thoughts"

  • GET all thoughts in the dataset with the query to sort them by time created in descending order and limit the amount of posts to 20
  • POST a thought to the dataset, with the schema properties:
    name: {
     type: String,
     required: false,
     minlenght: 2,
     maxlenght: 30,
     trim: true
    },
    message: {
     type: String,
     required: true,
     minlenght: 5,
     maxlenght: 140,
     trim: true
    },
    createdAt: {
     type: Date,
     default: () => new Date()
    },
    category: {
     type: String,
     required: false,
     enum:['Food thought', 'Project thought', 'Home thought']
    }
    
    

"/:thoughtId/like"

  • POST a like to a specific thought in the the array of thoughts

View it live

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%