Overview
El Atlas Device SDK para Node.js permite el desarrollo de aplicaciones utilizando los lenguajes JavaScript y TypeScript. El SDK de Node.js es más apto para escribir aplicaciones del lado del servidor. Tu aplicación Node.js puede ser un componente en una pila más amplia que también incluya aplicaciones iOS y Android.
The Node.js SDK is not suitable for front-end application development.
Due to limitations of the browser environment, it is not possible to build a browser-based web app with this SDK. For front-end web applications, use the Web SDK.
Para el desarrollo de aplicaciones móviles multiplataforma, use el SDK de React Native.
Requisitos previos
Antes de comenzar, asegúrese de que su entorno cumpla con los siguientes requisitos previos:
Node.js versión 12.x o posterior (incluida la versión 14 de Node.js)
Linux, macOS 10.8 (o posterior) o Windows 8 (o posterior)
Instalación
Follow these steps to create a Node.js project and add the Node.js SDK to it.
Tip
Atlas Device SDK and Realm
The SDK uses Realm Core database for device data persistence. When you install the Node.js SDK, the package names reflect Realm naming.
Create a Node.js Project
Cree su proyecto Node.js creando un nuevo directorio para su proyecto y ejecutando npm init En ese directorio. En el ejemplo a continuación, reemplaza MyApp con el nombre del proyecto que desees. Responde a todas las preguntas para completar los detalles de tu proyecto.
mkdir MyApp && cd MyApp && npm init
Habilite TypeScript (opcional)
TypeScript is a superset of JavaScript that adds static type checking and other features intended to make application-scale development more robust. If you'd like to use TypeScript, follow the TypeScript team's official Node Starter guide. The SDK supports TypeScript natively and integrates easily into a TypeScript project.
IoT Installation
Tip
Atlas Device SDK and Realm
The SDK uses Realm Core database for device data persistence. When you install the Node.js SDK, the package names reflect Realm naming.
To create a Node.js project and add the Node.js SDK on an Internet of Things (IoT) platform such as the Raspberry Pi 2, 3, or 4 running Raspberry Pi OS (formerly Raspbian), follow the steps below:
Instalar un compilador de C++
La biblioteca IoT del SDK de Node.js no se distribuye como archivo binario, por lo que debe compilarla desde el código fuente. Para ello, necesitará un compilador de C++ que funcione. Para instalarlo en su dispositivo IoT, ejecute el siguiente comando:
sudo apt install build-essential g++ libssl-dev
Create a Node.js Project
Crea tu proyecto Node.js creando un nuevo directorio para tu proyecto y ejecutando npm init en ese directorio. En el siguiente ejemplo, reemplace MyApp por el nombre de proyecto deseado. Responde a todos los indicios para rellenar los detalles de tu proyecto.
mkdir MyApp && cd MyApp && npm init
Habilite TypeScript (opcional)
TypeScript is a superset of JavaScript that adds static type checking and other features intended to make application-scale development more robust. If you'd like to use TypeScript, follow the TypeScript team's official Node Starter guide. The SDK supports TypeScript natively and integrates easily into a TypeScript project.
Import the SDK
Add the following line to the top of your source files (JavaScript or TypeScript) where you want to use the SDK:
import Realm from "realm";