What is @serverless/platform-client?
@serverless/platform-client is an npm package that provides a client for interacting with the Serverless Platform. It allows users to manage and deploy serverless applications, interact with the Serverless Framework Dashboard, and access various services provided by the Serverless Platform.
What are @serverless/platform-client's main functionalities?
Initialize the client
This code initializes the Serverless SDK client, which is the starting point for interacting with the Serverless Platform.
const { ServerlessSDK } = require('@serverless/platform-client');
const sdk = new ServerlessSDK();
Login to the Serverless Platform
This code demonstrates how to log in to the Serverless Platform using the SDK. This is necessary for performing authenticated operations.
const { ServerlessSDK } = require('@serverless/platform-client');
const sdk = new ServerlessSDK();
(async () => {
await sdk.login();
})();
Deploy a service
This code demonstrates how to deploy a service to the Serverless Platform. It requires the user to be logged in and provides details about the organization, application, service, and stage.
const { ServerlessSDK } = require('@serverless/platform-client');
const sdk = new ServerlessSDK();
(async () => {
await sdk.login();
const result = await sdk.deploy({
orgName: 'your-org',
appName: 'your-app',
serviceName: 'your-service',
stageName: 'dev',
inputs: {}
});
console.log(result);
})();
List services
This code demonstrates how to list all services within a specific organization. It requires the user to be logged in and provides the organization name.
const { ServerlessSDK } = require('@serverless/platform-client');
const sdk = new ServerlessSDK();
(async () => {
await sdk.login();
const services = await sdk.listServices({ orgName: 'your-org' });
console.log(services);
})();
Other packages similar to @serverless/platform-client
aws-sdk
The AWS SDK for JavaScript provides a comprehensive set of tools for interacting with AWS services. It is more general-purpose compared to @serverless/platform-client, which is specifically designed for the Serverless Platform. The AWS SDK supports a wide range of AWS services and is suitable for users who need to interact with AWS directly.
google-cloud
The Google Cloud Client Library for Node.js provides tools for interacting with Google Cloud services. Similar to the AWS SDK, it is more general-purpose and supports a wide range of Google Cloud services. It is suitable for users who need to interact with Google Cloud directly, whereas @serverless/platform-client is focused on the Serverless Platform.
azure-sdk-for-js
The Azure SDK for JavaScript provides tools for interacting with Azure services. It is a comprehensive library for managing Azure resources and services. Like the AWS and Google Cloud SDKs, it is more general-purpose and supports a wide range of Azure services, while @serverless/platform-client is focused on the Serverless Platform.