Skip to content

Latest commit

 

History

History

convert-phone-number-to-country-name

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

📱 Validate phone number and get it's country information

A Node Cloud Function that figures out country in which a phone number is registered.

Example input:

{
    "phoneNumber": "+421957215740"
}

Function can also accept phone numbers with spaces, for instance +421 957 215 740.

Example output:

{
    "phoneNumber": "+421957215740",
    "phonePrefix": "+421",
    "countryCode": "SK",
    "countryName": "Slovakia"
}

📝 Environment Variables

List of environment variables used by this cloud function:

  • APPWRITE_FUNCTION_ENDPOINT - Endpoint of your Appwrite server
  • APPWRITE_FUNCTION_API_KEY - Appwrite API Key
  • APPWRITE_FUNCTION_PROJECT_ID - Appwrite project ID. If running on Appwrite, this variable is provided automatically.

🚀 Deployment

  1. Clone this repository, and enter this function folder:
$ git clone https://github.com/open-runtimes/examples.git && cd examples
$ cd node/convert_phone_number_to_country_name
  1. Enter this function folder and build the code:
docker run --rm --interactive --tty --volume $PWD:/usr/code openruntimes/node:v2-17.0 sh /usr/local/src/build.sh

As a result, a code.tar.gz file will be generated.

  1. Start the Open Runtime:
docker run -p 3000:3000 -e INTERNAL_RUNTIME_KEY=secret-key -e INTERNAL_RUNTIME_ENTRYPOINT=index.js --rm --interactive --tty --volume $PWD/code.tar.gz:/tmp/code.tar.gz:ro openruntimes/node:v2-17.0 sh /usr/local/src/start.sh

Your function is now listening on port 3000, and you can execute it by sending POST request with appropriate authorization headers. To learn more about runtime, you can visit Node runtime README.

📝 Notes

  • This function is designed for use with Appwrite Cloud Functions. You can learn more about it in Appwrite docs.
  • This example is compatible with Node 17.0. Other versions may work but are not guaranteed to work as they haven't been tested.