-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #277 from plivo/SMS-5025
SMS-5025: Add Requester IP to Get and List Messages
- Loading branch information
Showing
12 changed files
with
153 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ docs/ | |
node_modules | ||
coverage | ||
dist | ||
node-sdk-test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM ubuntu:18.04 | ||
|
||
WORKDIR /usr/src/app | ||
RUN apt-get update && apt-get install -y wget git vim | ||
|
||
# Install node using nvm | ||
RUN mkdir -p /usr/src/.nvm | ||
ENV NVM_DIR /usr/src/.nvm | ||
RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | sh | ||
ENV NODE_VERSION v14.0.0 | ||
RUN /bin/sh -c ". $NVM_DIR/nvm.sh && nvm install $NODE_VERSION" | ||
|
||
ENV NODE_PATH $NVM_DIR/versions/node/$NODE_VERSION/lib/node_modules | ||
ENV PATH $NVM_DIR/versions/node/$NODE_VERSION/bin:$PATH | ||
|
||
# Copy setup script | ||
COPY setup_sdk.sh /usr/src/app/ | ||
RUN chmod a+x /usr/src/app/setup_sdk.sh | ||
|
||
ENTRYPOINT [ "/usr/src/app/setup_sdk.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.PHONY: build test | ||
|
||
build: | ||
docker-compose up --build --remove-orphans | ||
|
||
test: | ||
docker exec -it $$CONTAINER /bin/bash -c "npm install request --no-save && npm test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: '3' | ||
|
||
services: | ||
|
||
nodeSDK: | ||
build: | ||
context: . | ||
image: nodesdk | ||
container_name: nodeSDK | ||
environment: | ||
- PLIVO_AUTH_ID=${PLIVO_AUTH_ID} | ||
- PLIVO_AUTH_TOKEN=${PLIVO_AUTH_TOKEN} | ||
- PLIVO_API_DEV_HOST=${PLIVO_API_DEV_HOST} | ||
- PLIVO_API_PROD_HOST=${PLIVO_API_PROD_HOST} | ||
volumes: | ||
- .:/usr/src/app | ||
stdin_open: true | ||
tty: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
testDir="node-sdk-test" | ||
GREEN="\033[0;32m" | ||
NC="\033[0m" | ||
|
||
if [ ! $PLIVO_API_PROD_HOST ] || [ ! $PLIVO_API_DEV_HOST ] || [ ! $PLIVO_AUTH_ID ] || [ ! $PLIVO_AUTH_TOKEN ]; then | ||
echo "Environment variables not properly set! Please refer to Local Development section in README!" | ||
exit 126 | ||
fi | ||
|
||
cd /usr/src/app | ||
|
||
echo "Setting plivo-api endpoint to dev..." | ||
find /usr/src/app/lib/rest -type f -exec sed -i "s/$PLIVO_API_PROD_HOST/$PLIVO_API_DEV_HOST/g" {} \; | ||
|
||
echo "Packaging SDK..." | ||
echo "npm install" && npm install | ||
echo "npm run prepublish" && npm run prepublish | ||
echo "npm pack | tail -n 1" && package=$( npm pack | tail -n 1 ) | ||
|
||
if [ ! -d $testDir ]; then | ||
echo "Creating test dir..." | ||
mkdir -p $testDir | ||
fi | ||
|
||
if [ ! -f $testDir/test.js ]; then | ||
echo "Creating test file..." | ||
echo -e "let plivo = require('plivo')\n" > $testDir/test.js | ||
echo -e "\nlet client = new plivo.Client(process.env.PLIVO_AUTH_ID, process.env.PLIVO_AUTH_TOKEN);" >> $testDir/test.js | ||
fi | ||
|
||
echo "Installing dependencies for testing..." | ||
mv $package $testDir | ||
cd $testDir | ||
rm -rf package*.json node_modules | ||
npm init -y | ||
npm install $package | ||
rm $package | ||
|
||
echo -e "\n\nSDK setup complete!" | ||
echo "To test your changes:" | ||
echo -e "\t1. Add your test code in <path_to_cloned_sdk>/$testDir/test.js on host (or /usr/src/app/$testDir/test.js in the container)" | ||
echo -e "\t2. Run a terminal in the container using: $GREEN docker exec -it $HOSTNAME /bin/bash$NC" | ||
echo -e "\t3. Navigate to the test directory: $GREEN cd /usr/src/app/$testDir$NC" | ||
echo -e "\t4. Run your test file: $GREEN node test.js$NC" | ||
echo -e "\t5. For running unit tests, run on host: $GREEN make test CONTAINER=$HOSTNAME$NC" | ||
|
||
# To keep the container running post setup | ||
/bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters