Docs Home → Atlas App Services
You should migrate deprecated third-party service integrations to use
the corresponding official libraries available from npm . The
sections later on this page contain details and examples for each
service.
To migrate from a deprecated service:
Add a library for the service from
npm
to your app.
Import the library in your
functions. Replace any calls to the built-in service actions with
calls to the corresponding methods in the imported library.
If the service has webhooks, convert them to HTTPS endpoints.
Replace HTTP requests sent through an HTTP Service
client with calls to an HTTP library like node-fetch or axios.
Atlas App Services does not support v3 of node-fetch
. Use v2 instead.
exports = async function () { const http = context.services .get ("myHttp" ); const response = await http.get ({ url : "https://www.example.com" , headers : { "Content-Type" : [ "application/json" ] } }) return response.body .text () }
exports = async function () { const fetch = require ("node-fetch" ); const response = await fetch ("https://www.example.com" , { method : "GET" , headers : { "Content-Type" : "application/json" } }) return response.text () }
exports = async function () { const http = context.services .get ("myHttp" ); const response = await http.get ({ url : "https://www.example.com" , headers : { "Content-Type" : [ "application/json" ] } }) return response.body .text () }
exports = async function () { const axios = require ("axios" ); const response = await axios.get ("https://www.example.com" , { headers : { "Content-Type" : "application/json" } }) return response.data }
Replace calls through a Twilio Service client
with calls to the official Twilio Node Helper Library.
To authenticate Twilio requests, store your Account SID and Auth Token
as values . You can then access them within
functions and pass them to the SDK.
exports = async function () { const twilio = context.services .get ("myTwilio" ); twilio.send ({ to : "+15558675309" , from : "+15551234567" , body : "Hello from App Services!" , }); }
exports = async function () { const twilio = require ('twilio' )( context.values .get ("TwilioAccountSID" ), context.values .get ("TwilioAuthToken" ), ) await twilio.messages .create ({ to : "+15558675309" , from : "+15551234567" , body : "Hello from App Services!" , }) }
Replace calls through an AWS Service client with
calls to the official AWS JavaScript SDK.
App Services does not yet support version 3 of the AWS SDK. Use the version
2 SDK to replace the deprecated AWS Service in your functions.
To authenticate AWS requests, store your Access Key ID and Secret Access
Key as values . You can then access them
within functions and pass them to the SDK.
exports = async function () { const s3 = context.services .get ("myAWS" ).s3 ("us-east-1" );
const putResult = await s3.PutObject ({ Bucket : "bucketName" , Key : "keyName" , Body : EJSON .stringify ({ hello : "world" }), });
const getResult = await s3.GetObject ({ Bucket : "bucketName" , Key : "keyName" , }); }
exports = async function () { const S3 = require ('aws-sdk/clients/s3' ); const s3 = new S3 ({ accessKeyId : context.values .get ("awsAccessKeyId" ), secretAccessKey : context.values .get ("awsSecretAccessKey" ), region : "us-east-1" , }); const putResult = await s3.putObject ({ Bucket : "bucketName" , Key : "keyName" , Body : EJSON .stringify ({ hello : "world" }), }).promise (); const getResult = await s3.getObject ({ Bucket : "bucketName" , Key : "keyName" , }).promise (); }
exports = async function () { const kinesis = context.services .get ("myAWS" ).kinesis ("us-east-1" );
const putResult = await kinesis.PutRecord ({ Data : EJSON .stringify ({ hello : "world" }), StreamName : "myStream" , PartitionKey : "myPartition" , }); }
exports = async function () { const Kinesis = require ('aws-sdk/clients/kinesis' ); const kinesis = new Kinesis ({ accessKeyId : context.values .get ("awsAccessKeyId" ), secretAccessKey : context.values .get ("awsSecretAccessKey" ), region : "us-east-1" , });
const putResult = await kinesis.putRecord ({ Data : EJSON .stringify ({ hello : "world" }), StreamName : "myStream" , PartitionKey : "myPartition" , }).promise (); }
exports = async function () { const lambda = context.services .get ('MyAwsService' ).lambda ("us-east-1" );
const invokeResult = await lambda.Invoke ({ FunctionName : "myLambdaFunction" , Payload : EJSON .stringify ({ hello : "world" }), }); };
exports = async function () { const Lambda = require ('aws-sdk/clients/lambda' ); const lambda = new Lambda ({ accessKeyId : context.values .get ("awsAccessKeyId" ), secretAccessKey : context.values .get ("awsSecretAccessKey" ), region : "us-east-1" , });
const invokeResult = await lambda.invoke ({ FunctionName : "myLambdaFunction" , Payload : EJSON .stringify ({ hello : "world" }), }).promise (); }
exports = async function () { const ses = context.services .get ('MyAwsService' ).ses ("us-east-1" );
const sendResult = await ses.SendEmail ({ Source : "sender@example.com" , Destination : { ToAddresses : ["receiver@example.com" ] }, Message : { Body : { Html : { Charset : "UTF-8" , Data : `This is a message from user ${context.user.id} sent through AWS SES` } }, Subject : { Charset : "UTF-8" , Data : "Test Email Please Ignore" }, }, }); };
exports = async function () { const SES = require ('aws-sdk/clients/ses' ); const ses = new SES ({ accessKeyId : context.values .get ("awsAccessKeyId" ), secretAccessKey : context.values .get ("awsSecretAccessKey" ), region : "us-east-1" , });
const sendResult = await ses.sendEmail ({ Source : "sender@example.com" , Destination : { ToAddresses : ["receiver@example.com" ] }, Message : { Body : { Html : { Charset : "UTF-8" , Data : `This is a message from user ${context.user.id} sent through AWS SES` } }, Subject : { Charset : "UTF-8" , Data : "Test Email Please Ignore" }, }, }).promise (); }