├── .editorconfig
├── .eslintignore
├── .eslintrc.json
├── .gitattributes
├── .gitignore
├── .prettierrc
├── .travis.yml
├── CNAME
├── CONTRIBUTING.md
├── Procfile
├── README.md
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── index.html
└── manifest.json
└── src
├── app
├── App.css
├── App.js
├── App.test.js
└── assets
│ ├── image
│ ├── chatIcon.png
│ └── loops.png
│ ├── manifest.json
│ └── sound
│ └── ping.mp3
├── chatPage
├── chatIconPushNotification.png
├── chatPage.css
├── chatPage.js
├── test.js
└── user.png
├── index.js
├── loginPage
├── loginPage.css
└── loginPage.js
└── registerServiceWorker.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | end_of_line = lf
7 | indent_size = 2
8 | indent_style = space
9 | insert_final_newline = true
10 | max_line_length = 80
11 | trim_trailing_whitespace = true
12 |
13 | [*.md]
14 | max_line_length = 0
15 | trim_trailing_whitespace = false
16 |
17 | [COMMIT_EDITMSG]
18 | max_line_length = 0
19 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OTRChat/NodeChat/7a574466c36e89f31e570bba8399be20fd44ef28/.eslintignore
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "extends": [
4 | "airbnb",
5 | "prettier",
6 | "prettier/react"
7 | ],
8 | "plugins": [
9 | "prettier"
10 | ],
11 | "rules": {
12 | "prettier/prettier": ["error"],
13 | "quotes": ["error", "double"],
14 | "indent": ["error", "tab"],
15 | "react/jsx-indent": ["error", "tab"],
16 | "react/jsx-one-expression-per-line": 0,
17 | "react/jsx-filename-extension": [1, {"extensions": [".js",".jsx"]}],
18 | "react/prop-types": 0,
19 | "no-underscore-dangle": 0,
20 | "import/imports-first": ["error","absolute-first"],
21 | "import/newline-after-import": "error",
22 | "no-undef": [1],
23 | "no-console": [1]
24 | }
25 | }
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=false
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 | # testing
7 | /coverage
8 |
9 | # production
10 | /build
11 |
12 | # misc
13 | .DS_Store
14 | .env.local
15 | .env.development.local
16 | .env.test.local
17 | .env.production.local
18 |
19 | npm-debug.log*
20 | yarn-debug.log*
21 | yarn-error.log*
22 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "trailingComma": "es5",
3 | "useTabs": true,
4 | bracketSpacing: true,
5 | jsxBracketSameLine: true,
6 | semi: true
7 | }
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "stable"
4 |
5 | script:
6 | - npm run-script lint
7 |
--------------------------------------------------------------------------------
/CNAME:
--------------------------------------------------------------------------------
1 | chat.joshghent.com
2 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | ### Thank you for your interest in contributing to this project!
4 |
5 | Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue, assessing changes, and helping you finalize your pull requests.
6 |
7 | ### Contributions
8 | There are many ways to contribute, from improving the documentation, bug reports, feature requests or taking on a existing issues.
9 |
10 | # Code of conduct
11 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone
12 |
13 | When working on a issue, please post in that issue that you would like to work on it. A moderator will assign it to you and change the label. This will help clarify to others that a issue is already being worked on.
14 |
15 | # Getting started
16 |
17 | To start the app you need to have both the server and the react app running.
18 |
19 | ### Starting the server
20 | The server is available here https://github.com/OTRChat/server.
21 | Inside the server folder run the following commands.
22 | ```bash
23 | # Install the dependencies
24 | npm install
25 |
26 | # Run the server
27 | npm start
28 | ```
29 | ### Starting the react app
30 | Inside the react app folder run the following commands.
31 | ```bash
32 | # Install the dependencies
33 | npm install
34 |
35 | # Run the react app
36 | npm start
37 | ```
38 |
39 | ### Steps to submitting a contribution
40 | 1. Create your own fork of the code
41 | 2. Do the changes in your fork
42 | 3. If you like the change and think the project could use it send a pull request with your changes.
43 |
44 | # How to report a bug
45 |
46 | File an issue, make sure to answer these three questions:
47 | 1. What did you do?
48 | 2. What did you expect to see?
49 | 3. What did you see instead?
50 |
51 | # How to suggest a feature
52 | File an issue, explain the feature you want added and a moderator will review it.
53 |
54 | # Issue labeling conventions
55 | * Availble - an issue that is open for someone to work on.
56 | * Assigned - an issue that a someone is working on.
57 | * Good First Issue - issues that are smaller in size.
58 | * High Prioriy - an issue that we want to get resolved quickly.
59 | * Discussion - an issue that is being used to discuss a possible change or idea.
60 |
--------------------------------------------------------------------------------
/Procfile:
--------------------------------------------------------------------------------
1 | web: npm start
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NodeChat :speech_balloon:
2 |
3 | A group chat application written in Node and SocketIO.
4 |
5 | See it live [here](https://chat.joshghent.com).
6 |
7 | ## Project Vision
8 |
9 | To develop a robust chat application, that is able to act as a stand alone application and/or be embeded inside of a existing application.
10 |
11 | ### Use Cases
12 | * StandAlone Chat website
13 | * Customer Support Chat
14 | * Live Open Chat on a website
15 | * Private chat space on your website managed by you instead of thirdParty like Slack or Skype.
16 |
17 | ## Project Goal
18 | * Publish on [NPM](www.npmjs.com).
19 |
20 | ### Quick Start Guide
21 | To start the app you need to have both the server and the react app running.
22 |
23 | ### Starting the server
24 | The server is available here https://github.com/OTRChat/server.
25 | Inside the server folder run the following commands.
26 | ```bash
27 | # Install the dependencies
28 | npm install
29 |
30 | # Run the server
31 | npm start
32 | ```
33 | ### Starting the react app
34 | Inside the react app folder run the following commands.
35 | ```bash
36 | # Install the dependencies
37 | npm install
38 |
39 | # Run the react app
40 | npm start
41 | ```
42 |
43 | ### URL's
44 | The app is deployed with Heroku and configured to auto deploy the develop and master branch
45 | Development: https://joshghent-nodechat-staging.herokuapp.com/
46 | Master: https://chat.joshghent.com/
47 |
48 | Server development: https://joshghent-nodechat-server.herokuapp.com/
49 | Server master: https://joshghent-nodechat-server.herokuapp.com/
50 |
51 | If environment variables need updating as part of an update, then please ask one of the maintainers
52 |
53 | ### Contributing to this Project
54 |
55 | This project is open to anyone. Please read our CONTRIBUTING.md for more information.
56 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "node-chat",
3 | "version": "1.0.0",
4 | "private": true,
5 | "description": "Group chat with SocketIO",
6 | "main": "index.js",
7 | "author": "Josh Ghent",
8 | "license": "MIT",
9 | "scripts": {
10 | "lint": "prettier-eslint ./src/**/*.{js,jsx}",
11 | "start": "react-scripts start",
12 | "build": "react-scripts build",
13 | "test": "react-scripts test --env=jsdom",
14 | "eject": "react-scripts eject",
15 | "fix-code": "prettier-eslint --write 'src/**/*.{js,jsx}' ",
16 | "fix-styles": "prettier-stylelint --write 'src/**/*.{css,scss}' "
17 | },
18 | "repository": {
19 | "type": "git",
20 | "url": "git@github.com:joshghent/NodeChat.git"
21 | },
22 | "devDependencies": {
23 | "eslint": "^5.9.0",
24 | "eslint-config-airbnb": "^17.1.0",
25 | "eslint-config-prettier": "^3.3.0",
26 | "eslint-plugin-prettier": "^3.0.0",
27 | "eslint-plugin-react": "^7.11.1",
28 | "prettier": "^1.15.3",
29 | "prettier-eslint": "^8.8.2",
30 | "prettier-eslint-cli": "^4.7.1",
31 | "prettier-stylelint": "^0.4.2"
32 | },
33 | "dependencies": {
34 | "push.js": "1.0.9",
35 | "react": "^16.5.2",
36 | "react-dom": "^16.5.2",
37 | "react-scripts": "2.1.1",
38 | "shortid": "2.2.14",
39 | "socket.io": "^2.2.0",
40 | "socket.io-client": "^2.1.1"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OTRChat/NodeChat/7a574466c36e89f31e570bba8399be20fd44ef28/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
;
129 | }
130 | }
131 |
132 | export default LoginPage;
133 |
--------------------------------------------------------------------------------
/src/registerServiceWorker.js:
--------------------------------------------------------------------------------
1 | // In production, we register a service worker to serve assets from local cache.
2 |
3 | // This lets the app load faster on subsequent visits in production, and gives
4 | // it offline capabilities. However, it also means that developers (and users)
5 | // will only see deployed updates on the "N+1" visit to a page, since previously
6 | // cached resources are updated in the background.
7 |
8 | // To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
9 | // This link also includes instructions on opting out of this behavior.
10 |
11 | const isLocalhost = Boolean(
12 | window.location.hostname === "localhost" ||
13 | // [::1] is the IPv6 localhost address.
14 | window.location.hostname === "[::1]" ||
15 | // 127.0.0.1/8 is considered localhost for IPv4.
16 | window.location.hostname.match(
17 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
18 | )
19 | );
20 |
21 | export default function register() {
22 | if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
23 | // The URL constructor is available in all browsers that support SW.
24 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
25 | if (publicUrl.origin !== window.location.origin) {
26 | // Our service worker won't work if PUBLIC_URL is on a different origin
27 | // from what our page is served on. This might happen if a CDN is used to
28 | // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
29 | return;
30 | }
31 |
32 | window.addEventListener("load", () => {
33 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
34 |
35 | if (isLocalhost) {
36 | // This is running on localhost. Lets check if a service worker still exists or not.
37 | checkValidServiceWorker(swUrl);
38 |
39 | // Add some additional logging to localhost, pointing developers to the
40 | // service worker/PWA documentation.
41 | navigator.serviceWorker.ready.then(() => {
42 | console.log(
43 | "This web app is being served cache-first by a service " +
44 | "worker. To learn more, visit https://goo.gl/SC7cgQ"
45 | );
46 | });
47 | } else {
48 | // Is not local host. Just register service worker
49 | registerValidSW(swUrl);
50 | }
51 | });
52 | }
53 | }
54 |
55 | function registerValidSW(swUrl) {
56 | navigator.serviceWorker
57 | .register(swUrl)
58 | .then(registration => {
59 | registration.onupdatefound = () => {
60 | const installingWorker = registration.installing;
61 | installingWorker.onstatechange = () => {
62 | if (installingWorker.state === "installed") {
63 | if (navigator.serviceWorker.controller) {
64 | // At this point, the old content will have been purged and
65 | // the fresh content will have been added to the cache.
66 | // It's the perfect time to display a "New content is
67 | // available; please refresh." message in your web app.
68 | console.log("New content is available; please refresh.");
69 | } else {
70 | // At this point, everything has been precached.
71 | // It's the perfect time to display a
72 | // "Content is cached for offline use." message.
73 | console.log("Content is cached for offline use.");
74 | }
75 | }
76 | };
77 | };
78 | })
79 | .catch(error => {
80 | console.error("Error during service worker registration:", error);
81 | });
82 | }
83 |
84 | function checkValidServiceWorker(swUrl) {
85 | // Check if the service worker can be found. If it can't reload the page.
86 | fetch(swUrl)
87 | .then(response => {
88 | // Ensure service worker exists, and that we really are getting a JS file.
89 | if (
90 | response.status === 404 ||
91 | response.headers.get("content-type").indexOf("javascript") === -1
92 | ) {
93 | // No service worker found. Probably a different app. Reload the page.
94 | navigator.serviceWorker.ready.then(registration => {
95 | registration.unregister().then(() => {
96 | window.location.reload();
97 | });
98 | });
99 | } else {
100 | // Service worker found. Proceed as normal.
101 | registerValidSW(swUrl);
102 | }
103 | })
104 | .catch(() => {
105 | console.log(
106 | "No internet connection found. App is running in offline mode."
107 | );
108 | });
109 | }
110 |
111 | export function unregister() {
112 | if ("serviceWorker" in navigator) {
113 | navigator.serviceWorker.ready.then(registration => {
114 | registration.unregister();
115 | });
116 | }
117 | }
118 |
--------------------------------------------------------------------------------