/socket-io-typescript-chat

A chat application implemented using Socket.io, TypeScript, Angular and Angular Material components

Primary LanguageTypeScriptMIT LicenseMIT

A Socket.io Chat Example Using TypeScript

This repository contains server & client side code using TypeScript language.

Running Server and Client locally

Prerequisites(1)

First, ensure you have the following installed:

Check prerequisites' status:

git --version
node --version # (2)
npm --version 
google-chrome --version # (2)
npm list -g --depth 0 2>&1 | grep @angular/cli # (3)

(1) About installing Git, see How to Install Git on Linux, Mac or Windows, January 29, 2019 by Linode.
About installing Node.js, Npm, Node & Angular-CLI, see e.g. How to Install and Setup Angular 7 on Ubuntu 18.04.1, October 31, 2018 by Syamlal CM. For others OS, suitable similar articles are available on the net.

(2) To avoid trouble with Protractor 5.4.2, Node version should be at least 10.15.3 and Chrome version at least 75. Check that webdriver-manager is in version 12.1.4. If needed, run npm i -D protractor: with Node 10.15.3+, it will update webdriver-manager with the requiered version.

(3) See below about rechecking Angular-CLI's status under the project's folder.

Clone repository

In order to start the project use:

git clone https://github.com/atao60/socket-io-typescript-chat.git

cd socket-io-typescript-chat

npm install

All the npm scripts should now work as it under Windows and Linux.

Check @angular/cli and npm packages' status:

npm outdated # See notes below
npm audit
ng --version

About typescript: its version is constrained to ">=3.4 and <3.5" to please @angular/compiler-cli and @angular-devkit/build-angular.

Run - Development mode

Launch the application with:

npm start

Your browser will open a view with the following URL: http://localhost:4200.

With concurrently, both client and server sides are launched with Angular build, TypeScript compiler and Express server.

The socket.io server will be running on port 3000.

Both client side (Angular) and server side (Express) files are being watched. Any change automatically either restarts the Express server or reloads your browser.

Running tests

Run npm test to execute the frontend unit tests via Karma.

Run npm run e2e:start to execute the end-to-end tests via Protractor.

Running linters

Run npm run lint to execute both the frontend and backend TS linting via TSLint.

Run npm run lint:client to execute only the frontend TS linting via TSLint.

Run npm run lint:server to execute only the backend TS linting via TSLint.

Run npm run lint:html to execute the frontend HTML linting via HTMLHint.

Run npm run lint:scss to execute the frontend SCSS linting via SASS-Lint.

Contribution

Contributions are greatly appreciated. You can contribute by adding i18n support with your language, the testing section or any other feature.

Credits

This project is a fork of A Socket.io Chat Example Using TypeScript. A presentation and a live demo are available:

License

MIT