jdegand / chat-group-backend

Devchallenges - Legacy - Full-Stack Developer - Chat Group

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chat Group Backend

Solution for a challenge from Devchallenges.io.

Table of Contents

Overview

Built With

  • express generator
  • bcrypt
  • cookie-parser
  • cors
  • express
  • jsonwebtoken
  • mongoose
  • multer

Features

This application/site was created as a submission to a DevChallenges challenge. The challenge was to build an application to complete the given user stories.

Continued Development

  • left many routes open - could add JWTVerifys to all routes vs just the mutate routes (post, put, delete)
  • messages and channels are open - better to have a way to see the chat before signing in
  • need another server (socket.io) ? to have chat group be realtime across users - don't think so - because useEffect will update the view when channels and messages change
  • Promise.all() might be needed for multiple route calls in some functions - async - have to worry about order of results
  • add helmet ?
  • testing
  • seeding the database vs using my hacky way of creating a welcome channel if it doesn't exist
  • "select: false" in model vs removing field with .select('-password') vs removing field in populate call - what is best approach?
  • password field may be sent back in some calls - intermediate step - password forwarded along with userInfo then removed later - should exlude first and then forward or overly concerned - password is hashed and protected by jwt
  • can't pass two parameters to same route - express cant differentiate between them - need to add word in between i.e. /:channel/:id vs /:channel/id/:id
  • channel controller has a very convulted route because of that and it could be cleaned up
  • sorting with mongoose vs sorting response.data in the client - in React, use memo on the data.
  • multer and controllers don't mix
  • controllers considered an anti-pattern ?
  • getting file path is difficult - fakepath issues - can't get the file to save - the folder will be created - dir name in multer middleware
  • had issues with multer callback syntax - console.logs need to be inside functions inside callbacks
  • Added fs unlink logic to remove photos that are no longer tied to user profiles
  • Read about changes coming to Multer (2.0) so need to look out for that
  • Profile pictures come from freepik. Check below for links - the majority of pictures belong to the same series.
  • Added public/uploads to gitignore

How To Use

To clone and run this application, you'll need Git and Node.js (which comes with npm) installed on your computer. From your command line:

# Clone this repository
$ git clone https://github.com/jdegand/chat-group-backend

# Install dependencies
$ npm install

# Add env variables (PORT, MONGO_URI, REFRESH_TOKEN_SECRET, ACCESS_TOKEN_SECRET) and connect to mongo

# Run the app
$ npm start

Useful Resources

About

Devchallenges - Legacy - Full-Stack Developer - Chat Group


Languages

Language:JavaScript 98.4%Language:HTML 1.1%Language:CSS 0.5%