...
Expand |
---|
In 1.3.x, MongoDB Connection and MongoDB Collection objects were added to Typescript Module objects and when a connection (or a collection) is accessed using Mongoose from several files, the analyzer was creating one connection (or collection) object per such file. In order to avoid "added objects" and minimize the number of "deleted objects" when updating from 1.3.x to >=1.4.x a migration is carried out. This migration requires com.castsoftware.internal.platform version >= 0.8.5 to be used.
|
...
Behavior explanation
Serverless framework, Serverless Application Model (SAM), and Cloudformation are supported. These are frameworks using *.yml or *.json file to set up AWS environment.
Whenever the runtime set in these files is nodejs, the com.castsoftware.nodejs extension is responsible for creating the corresponding NodeJS AWS Lambda Function, NodeJS AWS Lambda Operation (which represent AWS APIGateway events), and NodeJS AWS Simple Queue objects (see com.castsoftware.nodejs documentation for source codes and example).
Warning |
---|
Since the com.castsoftware.nodejs extension is responsible for analyzing AWS deployment framework *.yml and *.json files the results of an analysis will depend on the version of com.castsoftware.nodjes used. |
...
What results can you expect?
When analyzing the following source code with a recent enough version of com.castsoftware.nodejs (≥ 2.6.0.beta1):
Code Block |
---|
provider:
name: aws
runtime: nodejs12.x
functions:
mylambda:
handler: handler.apilambda
events:
- http:
path: test
method: get
- sqs:
arn:
Fn::GetAtt:
- MyQueue
- Arn
environment:
stage: ${opt:stage}
resources:
Resources:
MyQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: "MyQueue" |
Assuming that the handler function is a TypeScript function, once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten):
Click to enlarge
...
Links
...
- createBucket
...
createMultipartUpload
createPresignedPost
abortMultipartUpload
completeMultipartUpload
deleteBucketAnalyticsConfiguration
deleteBucketCors
deleteBucketEncryption
deleteBucketInventoryConfiguration
deleteBucketLifecycle
deleteBucketMetricsConfiguration
deleteBucketPolicy
deleteBucketReplication
deleteBucketTagging
deleteBucketWebsite
deleteObjectTagging
deletePublicAccessBlock
getBucketAccelerateConfiguration
getBucketAcl
getBucketAnalyticsConfiguration
getBucketCors
getBucketEncryption
getBucketInventoryConfiguration
getBucketLifecycle
getBucketLifecycleConfiguration
getBucketLocation
getBucketLogging
getBucketMetricsConfiguration
getBucketNotification
getBucketNotificationConfiguration
getBucketPolicy
getBucketPolicyStatus
getBucketReplication
getBucketTagging
getBucketVersioning
getBucketWebsite
getObjectAcl
getObjectLegalHold
getObjectLockConfiguration
getObjectRetention
getObjectTagging
getPublicAccessBlock
getSignedUrl
- listBuckets
listBucketAnalyticsConfigurations
listBucketInventoryConfigurations
listBucketMetricsConfigurations
listMultipartUploads
listObjectVersions
listParts
- putBucketLogging
- putBucketAnalyticsConfiguration
putBucketLifecycleConfiguration
putBucketMetricsConfiguration
putBucketNotification
putBucketNotificationConfiguration
putBucketPolicy
putBucketReplication
putBucketRequestPayment
putBucketTagging
putBucketVersioning
putObjectAcl
putObjectLegalHold
putObjectLockConfiguration
putObjectRetention
putObjectTagging
putPublicAccessBlock
putBucketAccelerateConfiguration
putBucketAcl
putBucketCors
putBucketEncryption
putBucketInventoryConfiguration
putBucketLifecycle
upload
uploadPart
uploadPartCopy
...
- putObject
...
- deleteBucket
deleteObject
deleteObjects
...
- getObject
- getObjectTorrent
listObjects
listObjectsV2
...
- putBucketLogging
- putBucketAnalyticsConfiguration
Code samples
This code will create a S3 Bucket named "MyBucket" on an AWS server in region "REGION" and puts an object in it
Code Block | ||||
---|---|---|---|---|
| ||||
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'});
// Create S3 service object
s3 = new AWS.S3({apiVersion: '2006-03-01'});
// Create the parameters for calling createBucket
var bucketParams = {
Bucket : "MyBucket",
ACL : 'public-read'
};
// call S3 to create the bucket
s3.createBucket(bucketParams, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.Location);
}
});
params = {
// ...
Bucket: "MyBucket"
};
s3.putObject(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
}); |
What results can you expect?
Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten):
Analysis of the code sample
...
Links
...
sendMessage
- sendMessageBatch
- receiveMessage
Support for SDK
This code will publish a message into the "SQS_QUEUE_URL" queue:
Code Block | ||||
---|---|---|---|---|
| ||||
import * as AWS from "aws-sdk";
AWS.config.update({ region: 'REGION' });
const sqs = new AWS.SQS({apiVersion: '2012-11-05'});
const queueUrl = "SQS_QUEUE_URL"
const params = {
MessageBody: "This is a message",
QueueUrl: queueUrl,
MaxNumberOfMessages: 1,
VisibilityTimeout: 0,
};
sqs.sendMessage(params, function (err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.MessageId);
}
});
} |
This code will receive a message from the queue "SQS_QUEUE_URL"
Code Block | ||||
---|---|---|---|---|
| ||||
import * as AWS from "aws-sdk";
AWS.config.update({ region: 'REGION' });
const sqs = new AWS.SQS({apiVersion: '2012-11-05'});
const queueUrl = "SQS_QUEUE_URL"
const params = {
QueueUrl: queueUrl,
MaxNumberOfMessages: 1,
VisibilityTimeout: 0,
};
export class SqsReciver {
constructor() {
this.reciver();
}
private reciver(): void {
sqs.receiveMessage(params, (err, data) => {
// do something
});
}
} |
What results can you expect?
Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten):
Click to enlarge
When the evaluation of the queue name fails, a Node.js AWS SQS Unknown Publisher (or Receiver) will be created.
AWS Lambda framework analysis
See AWS Lambda support for Node.js - TypeScript.
Known limitations for AWS support
The use of AWS.SQS with promises is not supported. For instance no link would be created between the receiver and the handler function defined in .then() call in the following source code:
Code Block | ||
---|---|---|
| ||
this.sqs.receiveMessage(params).promise().then( () => {}) |
...
SQL Database Access
This extension supports some libraries offering access to SQL databases. The SQL frameworks analysis is based on the evaluation of the first argument of the "query()" and "execute()" method calls. The first argument is evaluated and if it corresponds to an SQL query, a CAST_TS_Query object is created. In the case where the first argument does not correspond to a SQL query, we evaluate the second argument if is exists. Text only and parameterized SQL queries are supported. This heuristic allows us to support a large number of SQL database frameworks.
...
Expand | ||
---|---|---|
In the following code:
In this example, a TypeScript query object is created and a callLink between the anonymous function and that query is added. The sql analyzer can then link that query with the corresponding table if the table exists. In the present case, this extension creates a useSelect link to the table 'titles': |
Links
Analysis of the TypeScript application will result in the following links:
...