Giter Site home page Giter Site logo

jchat's Introduction

Running instructions

Overview

It's an real-time chatting web app, that supporting chatting between multiple friends, adding friends, storing chatting history and caching offline message. let's play

Here is my post about this project, which includes project architecture, design and summary

Set up Docker for Running Environment

  • Download official docker image from docker hub
$ docker pull node
$ docker pull redis
$ docker pull mongo
  • Run mongodb container
$ docker run --name mongodb --expose 27017 -p 27017:27017 -d mongo
  • Run redis container
$ docker run --name redis --expose 6379 -p 6379:6379 -d redis
  • Run docker nodejs and link to redis and mongodb
$ docker run -it --name node --link redis:redis --link mongodb:mongodb -p 3000:3000 -p 8080:8080 -p 8989:8989 -v /path/to/your/working/directory/:/app -d node
  • port 3000: webpack hot reload
  • port 8080: nodejs app
  • port 8989: nodejs debugger port
  • note your node container ID by running docker ps -a then run command docker exec -it <container ID> /bin/bash (on Mac) to go inside the node container
  • install webpack globally npm install webpack -g at the root of the node container
  • change listening port 80 in file app.js at line 46 to 8080 for development environment
  • run webpack from /app to build module bundle
  • run npm install from /app folder to install all model dependencies
  • run 'npm start' from /app folder to run node app
  • done! Now you are browse to http://localhost:8080 to sign up JChat anc start to chat with your friends!

Set up WebPack for Development Environment

  • install WebPack Development Server in the node container
npm install webpack-dev-server -g
  • uncomment lines marked as uncomment in webpack config file
  • run WebPack development server in the node container to start hot reload
webpack-dev-server --hot --inline
  • run node server by opening another docker machine while running WebPack dev server
  • done

MongoDB command

  • add new fields if the specified field does not exist
db.users.update( {"_id": ObjectId("56fd8b59226076750236d579")}, { $set : {"friendList" :[ {"id": '', "chID": '', 'userName':'mike', 'userStatus':'online', 'imgSrc':'/images/avatar.ico'}]}})

debug mode of nodeJS

  • node --debug=8989 app.js

jchat's People

Contributors

jiangxiaoyong avatar newjs avatar

Stargazers

Atadzhan avatar

Watchers

James Cloos avatar Atadzhan 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.