Skip to content

nexmo-community/on-call-application-api

Repository files navigation

Vonage

Build an On-Call Application With Symfony, React Native and Vonage

This repository is the complete example for the accompanying post at: Community Repository

This branch is the introduction branch. For a more complete example of the code please checkout to the end-tutorial branch.

Table of Contents

Prerequisites

Getting Started

Generate JWT keypair

Because this project will be making use of a mobile app built in React Native, along with authentication being required, JWT will be generated. So certificates need to be generated in other to make the JWT tokens. In the root of your project, run the following three commands:

mkdir API/var/jwt
openssl genpkey -out API/var/jwt/private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096
openssl pkey -in API/var/jwt/private.pem -out API/var/jwt/public.pem -pubout

Exposing Your Application To the Internet

Making a phone call with Vonage, requires a virtual phone number with a webhook to log the events that happen when a phone call is made, answered, rejected, or ended. For the tutorial, ngrok is the service of choice to expose the application to the Internet. Install ngrok, and run the following command:

ngrok http 8080

Make sure to copy your ngrok HTTPS url as you'll need this later when configuring the project.

Environment Variables

Copy or rename .env.dist to .env.

First fields to be updated are the values for your database credentials and config. An example is shown below, but please use more secure credentials.

DATABASE_URL=mysql://db_user:db_password@mysql:3306/on_call?serverVersion=8.0

MYSQL_DATABASE=on_call
MYSQL_USER=db_user
MYSQL_PASSWORD=db_password
MYSQL_ROOT_PASSWORD=root_password

JWT_PASSPHRASE=<your jwt passphrase>

Start Docker

cd Docker
docker-compose up -d
composer install

Database Migrations

php bin/console doctrine:migrations:migrate

Data Fixtures

php bin/console doctrine:fixtures:load

Test it

Make a POST request to <ngrok Url>/api/login_check replacing the < and > with your ngrok url. The content type of the post request needs to be application/json and the body of the request needs to be similar to the following:

{
    "username": "[email protected]",
    "password": "test_pass"
}

On a successful request, you'll receive a JWT token in the response.

Run the App

In a new Terminal run the following two commands:

cd MobileApp
npm install
expo start

Code of Conduct

In the interest of fostering an open and welcoming environment, we strive to make participation in our project and our community a harassment-free experience for everyone. Please check out our Code of Conduct in full.

Contributing

We ❤️ contributions from everyone! Check out the Contributing Guidelines for more information.

contributions welcome

License

This project is subject to the MIT License

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published