跳转至

Bootstrap a new OSDK TypeScript application(引导创建新的 OSDK TypeScript 应用)

This page will walk you through the process of creating your frontend application on top of popular JavaScript frameworks using the @osdk/create-app CLI tool.

If you want to add OSDK support for an existing application, view our documentation on adding an OSDK to an existing application.

1: Prerequisites

Create a Developer Console application

Follow the steps listed in the create a new Developer Console application page.

Set up your token

Export your token in your local environment. Below is an example using a sample personal access token, but you can generate a longer-lived one in the Developer Console. This token should not be checked into source control because it is your personal access token.

export FOUNDRY_TOKEN=<YOUR-TOKEN-FROM-GETTING-STARTED-PAGE>

Check Node version

The Typescript SDK requires Node 18 or higher to work. To check what version of Node you are using, enter the command below:

node --version

2. Quick start with @osdk/create-app

Create your frontend application

Run the provided command and follow the interactive prompts to customize your project, including the project name and framework choice. On the Getting Started page, you will find application-specific information that will be prefilled in a command for you. Below is an example of this code, with placeholders inside the < > where your specific details will be filled:

npm create @osdk/app@latest -- \
    --application <RID OF YOUR DEVELOPER CONSOLE APPLICATION> \
    --foundryUrl <YOUR FOUNDRY URL> \
    --applicationUrl <SUBDOMAIN OF YOUR FOUNDRY URL USED FOR HOSTING> \
    --clientId <YOUR CLIENT ID> \
    --osdkPackage <YOUR PACKAGE NAME> \
    --osdkRegistryUrl <YOUR PACKAGE HOSTING URL> \
    --corsProxy false

:::callout{theme="neutral"} A prefilled command with all of these parameters can be found on the Getting Started page in the API Documentation section of the Developer Console, or on the Overview page. :::

Develop your frontend application

Your project files have now been generated in a directory based on the project name you entered. A local development server can be started by running the commands below:

cd <project-directory>
npm install
npm run dev

中文翻译


引导创建新的 OSDK TypeScript 应用

本文将指导您使用 @osdk/create-app CLI 工具,在主流 JavaScript 框架上创建前端应用。

如果您希望为现有应用添加 OSDK 支持,请参阅为现有应用添加 OSDK 文档。

1:前提条件

创建 Developer Console 应用

请按照创建新的 Developer Console 应用页面中的步骤进行操作。

设置令牌

在本地环境中导出您的令牌。以下示例使用了一个示例个人访问令牌(personal access token),您也可以在 Developer Console 中生成一个有效期更长的令牌。请注意,此令牌不应纳入源代码管理,因为它属于您的个人访问令牌。

export FOUNDRY_TOKEN=<您的入门页面令牌>

检查 Node 版本

TypeScript SDK 需要 Node 18 或更高版本才能运行。请使用以下命令检查您当前的 Node 版本:

node --version

2. 使用 @osdk/create-app 快速开始

创建前端应用

运行以下命令,并根据交互式提示自定义您的项目,包括项目名称和框架选择。在入门页面中,您将找到已预填到命令中的应用特定信息。以下是该代码的示例,其中 < > 内的占位符将替换为您的具体信息:

npm create @osdk/app@latest -- \
    --application <您的 Developer Console 应用 RID> \
    --foundryUrl <您的 Foundry URL> \
    --applicationUrl <用于托管的 Foundry URL 子域名> \
    --clientId <您的客户端 ID> \
    --osdkPackage <您的包名称> \
    --osdkRegistryUrl <您的包托管 URL> \
    --corsProxy false

:::callout{theme="neutral"} 您可以在 Developer Console 的 API 文档部分下的入门页面,或概览页面中找到已预填所有参数的完整命令。 :::

开发前端应用

项目文件现已根据您输入的项目名称生成到相应目录中。运行以下命令即可启动本地开发服务器:

cd <项目目录>
npm install
npm run dev