Skip to content

Vehicle gateway servers (HTTP REST API + TCP Server) and also TCP client to connect to communicate with with TCP server & REST API. HAPROXY roundrobin load-balancing used for horizontal scalability between TCP servers + uses Redis PubSub to collaborate and each command / reply their tcp clients.

Notifications You must be signed in to change notification settings

narainsagar/vehicle_gateway_server

Repository files navigation

Vehicle Server Gateway

The project is created using Nest framework TypeScript starter repository.

You may check INFO.md file for more info about the implementation and approach and more.

For TCP Client module you may check ./client/README.md file.

Installation

$ npm install

You might be need to provide your ENV variables in .env file (provide your configurations, if you want to.)

$ cp .env.sample .env

Requirements / Prerequisites:

For this project to run, you need following services / tools to be installed on your system, up and running.

  • Node.js & NPM
  • Redis
  • MySQL

I have also added docker docker-compose files for you so you can quickly run them without installing on your actual machine. Checkout /docker for it.

Important: Please make sure once the mysql is running.. you need to create a database called test_db (please verify the name in your configuration or use test_db as the default one). This is required only for first time.

This is all you need. :)

Once everything is installed, up and running, you can proceed to the next steps.

Running the REST-API server app:

Note: To run the project locally, make sure the redis and mysql running on your machine (you can verify and validate the configuration in .env file)

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Running the TCP server module:

$ npm run start:tcp

## Or, maybe run using `node`:
$ node tcp-server.js

Alternatively, you can also run the project by building docker image and using docker-compose, check the next steps.

Docker commands

NOTE: The TCP server runs inside the this main application container, where we have REST HTTP API server + TCP server runs together via docker-compose file:

  • docker-compose up

  • docker-compose down

  • docker-compose build

  • restart via docker-compose: docker-compose down && docker-compose build && docker-compose up

  • Build docker image: docker build -f Dockerfile .

Errors?

  • Error: listen EADDRINUSE: address already in use ::1:3400 ?
$ lsof -i :3400 # check PID
$ kill PID

Test

Note: Currently, only the setup for automation tests is already configured.

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Author(s)

About

Vehicle gateway servers (HTTP REST API + TCP Server) and also TCP client to connect to communicate with with TCP server & REST API. HAPROXY roundrobin load-balancing used for horizontal scalability between TCP servers + uses Redis PubSub to collaborate and each command / reply their tcp clients.

Topics

Resources

Stars

Watchers

Forks