Running SDK Server in a Heroku Environment

You can deploy and host this ServerSDK application in any node-supported server.

  1. Log in to your Heroku account.

  2. Click the New button and select Create a new App from Dashboard.

  3. Enter an app name and click the Create app button.

  4. Navigate to the Deploy tab. Follow the steps to install the Heroku CLI, create a new Git repository, and deploy your application.

    Server SDK Installation - Deploy

    After following the previous step, a folder is created containing the Heroku cloned/setup. You now must copy the ServerSDK into the Heroku cloned/setup folder. Copy all of the files located in vop_server_sdk/secure-server-reference-app. There is no need to copy the dist and node_modules folders.

  5. Paste the following into the Procfile file:

    1web: npm run start-prod-server

    The code runs the ServerSDK in Heroku after a code push.

  6. Open the Heroku cloned/setup folder in a terminal, commit and push the files to Heroku using the following commands:

    1$ git add .
    2$ git commit -am "make it better"
    3$ git push heroku master
  7. After you push the code, Heroku automatically detects it as a Node.JS app. Your log should look similar to the following after you push:

    1akodaganur:server-sdk-109-pref aminkodaganur$ heroku login
    2heroku: Press any key to open up the browser to login or q to exit:
    3Opening browser to https://cli-auth.heroku.com/auth/cli/browser/658be33b-6251-4700-ba48-1f5319f3a978?requestor=SFMyNTY.g3QAAAACZAAEZGF0YW0AAAAMNDkuMzcuMTY1Ljg2ZAAGc2lnbmVkbgYA14ka5HQB.G2_9GKq-Q_Lz8L7oFvJplCMG1MMVhr20pcscL6a48jU
    4Logging in... done
    5Logged in as akodaganur@vlocity.com
    6akodaganur:server-sdk-109-pref aminkodaganur$ git add .
    7akodaganur:server-sdk-109-pref aminkodaganur$ git commit -m "Intial commit"
    8[master 2492e4e] Intial commit
    9 1 file changed, 1 insertion(+), 1 deletion(-)
    10akodaganur:server-sdk-109-pref aminkodaganur$ git push heroku master
    11Enumerating objects: 8, done.
    12Counting objects: 100% (8/8), done.
    13Delta compression using up to 8 threads
    14Compressing objects: 100% (6/6), done.
    15Writing objects: 100% (6/6), 593 bytes | 593.00 KiB/s, done.
    16Total 6 (delta 4), reused 0 (delta 0)
    17remote: Compressing source files... done.
    18remote: Building source:
    19remote:
    20remote: -----> Node.js app detected
    21remote:
    22remote: -----> Creating runtime environment
    23remote:
    24remote:        NPM_CONFIG_LOGLEVEL=error
    25remote:        NODE_ENV=production
    26remote:        NODE_MODULES_CACHE=true
    27remote:        NODE_VERBOSE=false
    28remote:
    29remote: -----> Installing binaries
    30remote:        engines.node (package.json):  12.16.3
    31remote:        engines.npm (package.json):   6.14.4
    32remote:
    33remote:        Resolving node version 12.16.3...
    34remote:        Downloading and installing node 12.16.3...
    35remote:        npm 6.14.4 already installed with node
    36remote:
    37remote: -----> Restoring cache
    38remote:        - node_modules is checked into source control and cannot be cached
    39remote:
    40remote: -----> Installing dependencies
    41remote:        Prebuild detected (node_modules already exists)
    42remote:        Rebuilding any native modules
    43remote:
    44remote:        > protobufjs@6.9.0 postinstall /tmp/build_527a1f8d/node_modules/protobufjs
    45remote:        > node scripts/postinstall
    46remote:
    47remote:
    48remote:        > core-js@3.6.5 postinstall /tmp/build_527a1f8d/node_modules/core-js
    49remote:        > node -e "try{require('./postinstall')}catch(e){}"
    50remote:
    51remote:
    52remote:        > fsevents@1.2.13 install /tmp/build_527a1f8d/node_modules/fsevents
    53remote:        > node install.js
    54remote:
    55remote:
    56remote:        Skipping 'fsevents' build as platform linux is not supported
    57remote:
    58remote:        > nodemon@1.19.4 postinstall /tmp/build_527a1f8d/node_modules/nodemon
    59remote:        > node bin/postinstall || exit 0
    60remote:
    61remote:        Love nodemon? You can now support the project via the open collective:
    62remote:         > https://opencollective.com/nodemon/donate
    63remote:
    64remote:        @types/compression@1.7.0 /tmp/build_527a1f8d/node_modules/@types/compression
    65remote:        @types/express@4.17.6 /tmp/build_527a1f8d/node_modules/@types/express
    66remote:        @types/body-parser@1.19.0 /tmp/build_527a1f8d/node_modules/@types/body-parser
    67remote:        @types/connect@3.4.33 /tmp/build_527a1f8d/node_modules/@types/connect
    68remote:        @types/node@13.13.5 /tmp/build_527a1f8d/node_modules/@types/node
    69remote:        @types/express-serve-static-core@4.17.7 /tmp/build_527a1f8d/node_modules/@types/express-serve-static-core
    70remote:        @types/qs@6.9.2 /tmp/build_527a1f8d/node_modules/@types/qs
    71remote:        @types/range-parser@1.2.3 /tmp/build_527a1f8d/node_modules/@types/range-parser
    72remote:        @types/serve-static@1.13.3 /tmp/build_527a1f8d/node_modules/@types/serve-static
    73remote:        @types/mime@2.0.1 /tmp/build_527a1f8d/node_modules/@types/mime
    74remote:        @types/cookie-parser@1.4.2 /tmp/build_527a1f8d/node_modules/@types/cookie-parser
    75remote:        @types/cors@2.8.6 /tmp/build_527a1f8d/node_modules/@types/cors
    76remote:        @types/express-session@1.17.0 /tmp/build_527a1f8d/node_modules/@types/express-session
    77remote:        @types/jsonwebtoken@8.3.9 /tmp/build_527a1f8d/node_modules/@types/jsonwebtoken
    78remote:        @types/request-promise@4.1.46 /tmp/build_527a1f8d/node_modules/@types/request-promise
    79remote:        @types/bluebird@3.5.30 /tmp/build_527a1f8d/node_modules/@types/bluebird
    80remote:        @types/request@2.48.4 /tmp/build_527a1f8d/node_modules/@types/request
    81remote:        @types/caseless@0.12.2 /tmp/build_527a1f8d/node_modules/@types/caseless
    82remote:        @types/tough-cookie@4.0.0 /tmp/build_527a1f8d/node_modules/@types/tough-cookie
    83remote:        form-data@2.5.1 /tmp/build_527a1f8d/node_modules/form-data
    84remote:        asynckit@0.4.0 /tmp/build_527a1f8d/node_modules/asynckit
    85remote:        combined-stream@1.0.8 /tmp/build_527a1f8d/node_modules/combined-stream
    86remote:        delayed-stream@1.0.0 /tmp/build_527a1f8d/node_modules/delayed-stream
    87remote:        mime-types@2.1.27 /tmp/build_527a1f8d/node_modules/mime-types
    88remote:        mime-db@1.44.0 /tmp/build_527a1f8d/node_modules/mime-db
    89remote:        @types/spdy@3.4.4 /tmp/build_527a1f8d/node_modules/@types/spdy
    90remote:        @vlocity-cme-sdk/digitalcommerce-sdk@107.1.0 /tmp/build_527a1f8d/node_modules/@vlocity-cme-sdk/digitalcommerce-sdk
    91remote:        @vlocity-cme-sdk/translation-sdk@107.1.0 /tmp/build_527a1f8d/node_modules/@vlocity-cme-sdk/translation-sdk
    92remote:        body-parser@1.19.0 /tmp/build_527a1f8d/node_modules/body-parser
    93remote:        bytes@3.1.0 /tmp/build_527a1f8d/node_modules/bytes
    94remote:        content-type@1.0.4 /tmp/build_527a1f8d/node_modules/content-type
    95remote:        debug@2.6.9 /tmp/build_527a1f8d/node_modules/debug
    96remote:        ms@2.0.0 /tmp/build_527a1f8d/node_modules/ms
    97remote:        depd@1.1.2 /tmp/build_527a1f8d/node_modules/depd
    98remote:        http-errors@1.7.2 /tmp/build_527a1f8d/node_modules/http-errors
    99remote:        inherits@2.0.3 /tmp/build_527a1f8d/node_modules/inherits
    100remote:        setprototypeof@1.1.1 /tmp/build_527a1f8d/node_modules/setprototypeof
    101remote:        statuses@1.5.0 /tmp/build_527a1f8d/node_modules/statuses
    102remote:        toidentifier@1.0.0 /tmp/build_527a1f8d/node_modules/toidentifier
    103remote:        iconv-lite@0.4.24 /tmp/build_527a1f8d/node_modules/iconv-lite
    104remote:        safer-buffer@2.1.2 /tmp/build_527a1f8d/node_modules/safer-buffer
    105remote:        on-finished@2.3.0 /tmp/build_527a1f8d/node_modules/on-finished
    106remote:        ee-first@1.1.1 /tmp/build_527a1f8d/node_modules/ee-first
    107remote:        qs@6.7.0 /tmp/build_527a1f8d/node_modules/qs
    108remote:        raw-body@2.4.0 /tmp/build_527a1f8d/node_modules/raw-body
    109remote:        unpipe@1.0.0 /tmp/build_527a1f8d/node_modules/unpipe
    110remote:        type-is@1.6.18 /tmp/build_527a1f8d/node_modules/type-is
    111remote:        is-stream@2.0.0 /tmp/build_527a1f8d/node_modules/gcs-resumable-upload/node_modules/is-stream
    112remote:        node-fetch@2.6.0 /tmp/build_527a1f8d/node_modules/gcs-resumable-upload/node_modules/node-fetch
    113remote:        mime@2.4.6 /tmp/build_527a1f8d/node_modules/@google-cloud/storage/node_modules/mime
    114remote:        readable-stream@3.6.0 /tmp/build_527a1f8d/node_modules/@google-cloud/storage/node_modules/readable-stream
    115remote:        xdg-basedir@4.0.0 /tmp/build_527a1f8d/node_modules/@google-cloud/storage/node_modules/xdg-basedir
    116remote:        nodemon@1.19.4 /tmp/build_527a1f8d/node_modules/nodemon
    117remote:        debug@3.2.6 /tmp/build_527a1f8d/node_modules/nodemon/node_modules/debug
    118remote:        ms@2.1.2 /tmp/build_527a1f8d/node_modules/nodemon/node_modules/ms
    119remote:        Installing any new modules (package.json)
    120remote:        removed 1 package and audited 626 packages in 4.606s
    121remote:
    122remote:        33 packages are looking for funding
    123remote:          run `npm fund` for details
    124remote:
    125remote:        found 25 vulnerabilities (19 low, 6 high)
    126remote:          run `npm audit fix` to fix them, or `npm audit` for details
    127remote:
    128remote: -----> Build
    129remote:        Running build
    130remote:
    131remote:        > express-typescript@1.0.0 build /tmp/build_527a1f8d
    132remote:        > tsc
    133remote:
    134remote:
    135remote: -----> Caching build
    136remote:        - node_modules
    137remote:
    138remote: -----> Pruning devDependencies
    139remote:        removed 210 packages and audited 412 packages in 4.776s
    140remote:
    141remote:        33 packages are looking for funding
    142remote:          run `npm fund` for details
    143remote:
    144remote:        found 24 vulnerabilities (19 low, 5 high)
    145remote:          run `npm audit fix` to fix them, or `npm audit` for details
    146remote:
    147remote: -----> Build succeeded!
    148remote: -----> Discovering process types
    149remote:        Procfile declares types -> web
    150remote:
    151remote: -----> Compressing...
    152remote:        Done: 48.3M
    153remote: -----> Launching...
    154remote:        Released v28
    155remote:        https://server-sdk-109-pref.herokuapp.com/ deployed to Heroku
    156remote:
    157remote: Verifying deploy... done.
    158To https://git.heroku.com/server-sdk-109-pref.git
    159   455a853..2492e4e  master -> master
    160akodaganur:server-sdk-109-pref aminkodaganur$

Note that the base API URL is logged at the end. Once you pushed and deployed successfully, the base URL becomes: https://your-app-name.herokuapp.com/v1/serversdk. You can also find the name in the Heroku Dashboard > Settings > Domains.

To verify whether the Heroku setup is working, open a browser and navigate to https://your-app-name.herokuapp.com/v1/serversdk/getcurrencydetails. The default currency details are displayed.

1:::note
2
3`/v1/serversdk` is a default API prefix which can be changed to: `vop_server_sdk/secure-server-reference-app/sdkConfig.ts`/
4
5:::