Installation

This guide describes how to install the application and server solely to run on an emulator. To run the application on a real device, you need to start your server and specify the hosts of your server in Config file. To start your server, you need to install everything as described in this guide and start the server using the flag production See here.

Installation and running on localhost

Solely for testing purposes on a real device, you can use the hosts of my server, use them in the configuration file

1. Socket Server

Socket server uses Redis for messaging between API and socket server

First we need to install and run Redis. You can use Redis installation guide

Starting Redis

$ redis-server

You can set a password for Redis, after which you will need to enter the Redis password into config file socket server and api server. See Config file

In socket-server directory

$ yarn install

Next

$ yarn development

2. API Server

First install MongoDB. Installation Guide.

Starting MongoDB

$ mkdir messenger
$ mongod --dbpath messenger

In messenger-api directory

$ yarn install
$ yarn development

3. Setup AWS S3

How to create bucket

How to add Policy

Policy for this project
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1458840156000",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetObjectVersion",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:PutObjectVersionAcl"
],
"Resource": [
"arn:aws:s3:::my-bucket/*"
]
}
]
}

When my-bucket is your bucket name

Put your AWS S3 data into config file. More here

4. Messenger Application.

In messenger-app directory

$ yarn install
$ expo start

Running on Production

To run Socket Server and API server, uses the package PM2.

To start the process PM2, you can use commands: yarn production this will launch a server with configurations for production, yarn staging this will launch a server with configurations for staging. See Config file.

To run you need to change config files

Socket server

$ yarn production
# or
# $ yarn staging

API Server

$ yarn build
$ yarn production
# or
# $ yarn staging

Messenger Application

Just set production mode. See here. This will launch Expo with a production configuration.

Note

Also for Socket Server and API Server there is a command yarn start-as-prod. This starts the server with configuration settings for production without build and PM2. It is needed to develop an application on the localhost using the production configuration

To run all the commands you can also use npm run