/allChat

An Online chat web application based on egg.js and socket.io.

Primary LanguageJavaScriptMIT LicenseMIT

allChat

The project allChat is one of components of project hifi_wechat which based on nodejs express frame, wechat SDK and socket.io. In this project I rewrite it with egg.js, added some new features and optimized. I only spend 3 days to re-construct the project, maybe there are many problems remained. If you find any bugs, wish you can concat me or help me fix it. Thanks!.

You might need to know egg.js and webpack first.

QuickStart

It's easy to start allChat on your computer. Please notice that my nodejs version is 8.9.0.

  1. Fetch allChat.
$ git clone https://github.com/PorYoung/allChat.git
  1. Go to the project directory and install dependencies.
$ npm i
  1. You might need use webpack-cli to build static files.
$ npm i webpack-cli -g
$ npm run build
  1. run egg.js project
$ npm run dev
  1. Don't forget the database which I used mongodb, install it and start it directly, the connection configuration is in config/config.default.js. It's egg-mongoose here, which help you use mongoose in egg app.
config.mongoose = {
  client: {
    url: 'mongodb://127.0.0.1/chat',
    options: {},
  },
};

see [egg docs][egg] and webpack docs for more detail.

Npm Scripts

  • Use npm run lint to check code style.
  • Use npm test to run unit test.
  • Use npm run autod to auto detect dependencies upgrade, see autod for more detail.
  • Use npm run watch to start webpack-cli watch.

Structure

  • app: server end code, see egg Directory Structure for more detail.
  • build: which contain the webpack config file and web front-end code. See webpack docs for configuration help.
  • .vscode: VS Code configuration, that's not important.
  • config: egg app configuration, see egg Configuration for more detail.
  • log: log files.
  • test: egg unit test.

Some Dependencies

  • socket.io: websocket frame, FEATURING THE FASTEST AND MOST RELIABLE REAL-TIME ENGINE, see its website.
  • egg-mongoose: use mongoose in egg.
  • egg-ejs: use ejs to render html file.
  • bootstrap, jquery and other the third part plugin for web front pages, and underscroe can be removed when you replace _.compile() with ${}.
  • etc.

Other Tips

  • the Server default listening port is 7001
  • the socket client connect to host 127.0.0.1, you might to modify it if you need to run not at your local computer.
  • waiting for updating...

Questions & Suggestions

Please open an issue here.

License

MIT