GithubHelp home page GithubHelp logo

annahasselstrom / project-happy-thoughts-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from technigo/project-happy-thoughts-api

0.0 0.0 0.0 95 KB

In this project I use Express and Mongodb to build an API that includes both GET request endpoints to return data and POST endpoints to create data. ❤️

Home Page: https://project-happy-thoughts-anna.herokuapp.com/

JavaScript 100.00%
mongodb mongoose api express-js mongodb-atlas heroku-deployment

project-happy-thoughts-api's Introduction

Project Happy Thoughts API ❤️

In this project I use Express and Mongodb to build an API that includes both GET request endpoints to return data and POST endpoints to create data.

View it live 👀

https://project-happy-thoughts-anna.herokuapp.com/

https://inspiring-lalande-9954d9.netlify.app/

Learnings 🤓

  • How to use POST requests to send data to your API
  • How to store data in your database from POST requests
  • How to validate data and ensure your database only contains 'good' data

Making it work 👍

In my earlier project - Happy Thoughts - I built a frontend in React which uses an API I created to store messages. In this new project, I have built my own API which works in the same way and I used that one to replace the API I used before in the React frontend.

In the first project I built a frontend that has a form to write a new 'happy thought', lists recent thoughts/messages, and shows a count of 'hearts' on each message. Users could then click the heart to like a message.

In order to replace the API I built, I build a 'Message' Mongoose model which has properties for the 'message' string, a 'heart' property for tracking the number of likes, and a 'createdAt' property to store when the message was added.

I then added 3 endpoints.

Each of the Message model's properties has special rules/validations:

  • 'message' - the text of the message

    • Required
    • Min length of 5 characters
    • Max length of 140 characters
  • 'hearts' - the number of heart clicks this message has received

    • Defaults to '0'
    • Should not be re-assignable
  • 'createdAt' - the time the message was added to the database

    • Defaults to the current time
    • Should not be re-assignable

project-happy-thoughts-api's People

Contributors

annahasselstrom avatar dependabot[bot] avatar emolsz avatar idlefingers avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.