Coder Social home page Coder Social logo

neighbor-chat-frontend-final's Introduction

Neighbor Chat

Table of Contents

General Info

Demo

Technologies

Setup

Features

Code Examples

Inspiration

Contact

General Info

Neighbor Chat is a chat platform for sharing, helping, and connecting with neighbors on your block. The back end repo for this project can be found here.

Demo

https://youtu.be/pfJHJe_RP2M

Technologies

  • React
  • Node.js
  • Express
  • Socket.io
  • PostgreSQL

Setup

First, fork and clone the backend repo. Open the code, run "npm install" and "npm start". Then fork and clone the frontend repo, open the code, run "npm install" and "npm start." Run "npm start" from another tab in your terminal to log in a second user for chatting.

Features

  • User authorization and login/logout.
  • Chat with neighbors in real time.
  • View your neighbors' profiles, including their name, photo, and address.
  • Edit/update your profile.
  • Add neighbors to your contacts list.

Code Examples

useEffect(() => {
    validateUser();
    divRef.current.scrollIntoView({ behavior: "smooth" });
    socket.on("connect", () => {
      console.log("socket connected?", socket.connected);
    });
    socket.on("chat message", (newMessage) => {
      setMessages([...messages, newMessage]);
    });
    return () => socket.off("chat message");
  }, [messages]);
router.post("/login", (request, response) => {
  const { user } = request.body;

  User.query()
    .findOne({ username: user.username || "" })
    .withGraphFetched("friends")
    .then((existingUser) => {
      if (!existingUser) {
        response.status(401).json({ error: "Invalid username/password." });
      } else {
        bcrypt
          .compare(user.password, existingUser.password_digest)
          .then((isMatch) => {
            if (!isMatch) {
              response
                .status(401)
                .json({ error: "Invalid username/password." });
            } else {
              const secret = process.env.AUTH_SECRET;
              const payload = { user_id: existingUser.id };
              const token = jwt.sign(payload, secret);
              response.status(200).json({ token, user: existingUser });
            }
          });
      }
    });
});

Inspiration

With the recent shift toward remote work, we are seeing and communicating with our neighbors more often. Neighbor Chat was created as a way to facilitate sharing, helping, and connecting with those who live close by.

Contact

Neighbor Chat was created by Haley Warson.

Contact me with any questions.

neighbor-chat-frontend-final's People

Contributors

haleywarson avatar

Stargazers

Joshua Blackham avatar

Watchers

 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.