You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
Node.js SDK
Install TLS SDK for Node.js
Copy page
Download PDF
Install TLS SDK for Node.js
Before you use Torch Log Service (TLS) SDK for Node.js to call TLS API actions and implement relevant features, install the SDK. This topic describes how to install TLS SDK for Node.js.​
Before you begin​
  • Create and get a Volcano Engine AccessKey pair.​
  • The AccessKey pair has the permissions to access all API actions. We recommend that you use an IAM user to call API actions or perform routine O&M. Before you use an IAM user, use a Volcano Engine account to grant the IAM user the permissions to operate TLS resources.​
Preparing a development environment​
TLS SDK for Node.js is built in the Node.js environment. Before you integrate the SDK, download and install Node.js. For information on the download URL and relevant operations, visit the Node.js official website.​
Installing the SDK​
  1. Create a project and enter the project directory.​
  1. Run the following command to initialize the SDK, and configure npm initialization as prompted:​
  • ​
    npm init​
    ​
  • After the initialization, npm automatically creates a configuration file named package.json. The file content is as follows:​
  • ​
    {​
    "name": "nodejs",​
    "version": "1.0.0",​
    "description": "",​
    "main": "index.js",​
    "scripts": {​
    "test": "echo \"Error: no test specified\" && exit 1"​
    },​
    "author": "",​
    "license": "ISC"​
    }​
    ​
  1. Install the SDK using npm.​
tip​
If a network error occurs when you use npm, we recommend that you use the specified npm image.​
  • ​
    npm install @volcengine/openapi​
    ​
  • After you run the command, the @volcengine/openapi information is automatically added to the package.json file. File content:​
  • ​
    {​
    "name": "nodejs-doc",​
    "version": "1.0.0",​
    "description": "",​
    "main": "index.js",​
    "scripts": {​
    "test": "echo \"Error: no test specified\" && exit 1"​
    },​
    "author": "",​
    "license": "ISC",​
    "dependencies": {​
    "@volcengine/openapi": "^1.2.2"​
    }​
    }​
    ​
  1. Build a project using Express.​
  • This section builds a project using Express as an example. You can use other methods to build a Node.js project as needed.​
  1. Run the following npm command to install Express.​
  • ​
    npm install express​
    ​
  1. Run the following npm command to install morgan:​
  • ​
    npm install morgan​
    ​
  1. Create a file named app.js and add the following code:​
  • ​
    var express = require('express')​
    var morgan = require('morgan')​
    var app = express()​
    const logger = morgan(function (tokens, req, res) {​
    return [​
    tokens.method(req, res),​
    tokens.url(req, res),​
    tokens.status(req, res),​
    tokens.res(req, res, 'content-length'), '-',​
    tokens['response-time'](req, res), 'ms'​
    ].join(' ')​
    })​
    app.use(logger)​
    app.get('/', (req, res) => res.send('Hello World!'))​
    app.listen(3001, () => console.log('Listening on port 3001!'))​
    ​
  1. Run the following command to start the project:​
  • ​
    node app.js​
    ​
  • The following output is displayed, which indicates that the project is started as expected.​
  • ​
    Listening on port 3001!​
    ​
​
Last updated: 2025.10.11 16:44:07