Cómo registrar un dominio utilizando Node y la API de DNSimple en 5 minutos

Rate this content
Bookmark

En esta breve charla relámpago registraré un dominio y demostraré cómo utilizar el cliente de la API de DNSimple para NodeJS para registrar un nombre de dominio y configurar el DNS necesario para que apunte a un servicio web en solo unos minutos.

6 min
17 Feb, 2022

Video Summary and Transcription

La charla de hoy es una demostración del cliente de nodo DnSimple, que incluye el proceso de instalación, autenticación, verificación de disponibilidad de dominios y registro. El orador enfatiza la importancia de realizar pruebas en el entorno de prueba antes de pasar a producción. También se cubre la configuración de registros DNS y el registro de dominios, con la importancia de verificar la funcionalidad del código. Información adicional sobre otros clientes y la API de DNSimple está disponible en dnsimple.com/API.

Available in English

1. Introducción al cliente de DnSimple para Node

Short description:

Hoy les voy a dar una demostración del cliente de DnSimple para Node. Primero, instalo el cliente de DnSimple usando npm. Luego, obtengo un token de mi cuenta de Sandbox para usar la API. A continuación, escribo el primer fragmento de código para autenticarme usando el token. Después de eso, verifico si el dominio está disponible y lo registro si lo está. Paso el ID de la cuenta y el nombre de dominio al cliente para la solicitud.

Hola Node Congress. Hoy les voy a dar una demostración del cliente de DnSimple para Node durante 5 minutos.

Primero, instalo el cliente de DnSimple usando npm. Una vez hecho eso, necesito obtener un token. Voy a obtenerlo de mi cuenta de Sandbox ahora. Este token me permitirá usar la API. Una vez que tenga ese token, el siguiente paso es instalar .env, lo cual nos permitirá obtener el valor del token desde un archivo de entorno. Ahora que eso está hecho y tengo configurado el token, lo siguiente que voy a hacer es escribir el primer fragmento de código. Solo quiero verificar que pueda autenticarme usando ese token que he creado. Como pueden ver, es bastante sencillo. Requerimos el cliente. Vamos a establecer la URL base en la URL de Sandbox para comenzar, de modo que podamos hacer testing allí. Obtengo el token de acceso del entorno del proceso y luego lo siguiente que voy a hacer es obtener los detalles de la cuenta usando el cliente, así que le pregunto quién soy. Me dará una respuesta y simplemente la registraré por el momento. Ahora cuando ejecute ese código, verán que funciona y se conecta a nuestro entorno de Sandbox y obtiene mi información. Ahora voy a tomar el ID de la cuenta y guardarlo en una variable y luego voy a usar ese ID de cuenta para verificar si el dominio está disponible. Antes de registrar un dominio, debemos asegurarnos de que esté disponible. Vamos a obtener el nombre de dominio de los argumentos de la línea de comandos. Con el nombre de dominio y el ID de cuenta, vamos a hacer una llamada al cliente para determinar si el dominio está disponible. Por ahora, vamos a tomar la respuesta de esa llamada y simplemente imprimirlo en la consola. Como pueden ver, al ejecutar esto ahora con un nombre de dominio pasado para un dominio que ya está registrado en Sandbox, muestra que no está disponible. Sin embargo, al ejecutar el mismo comando para un dominio que está disponible en Sandbox, muestra que la bandera de disponible está configurada en verdadero. Con el conocimiento de si el dominio está disponible o no, podemos continuar con el proceso y registrarlo si está disponible. Así que verificamos si esa bandera está configurada, si está disponible, entonces procederemos a llamar al cliente nuevamente y registrar el dominio. Si no está disponible, simplemente mostraremos un mensaje diciendo que no está disponible. Llamar al cliente es bastante sencillo, debes pasar el ID de la cuenta y el nombre de dominio, así como atributos para la solicitud. El único atributo requerido es el ID del registrante. Este es tu ID de contacto de DINSimple. Por lo general, esto se agregará de antemano o es algo que puedes agregar a través de la API. No voy a demostrar eso hoy, pero hay llamadas para agregar y gestionar contactos a través de la API. Por ahora, estamos pasando el ID a través de la línea de comandos.

2. Configuración de registros DNS y registro de dominios

Short description:

Ten en cuenta que todavía estamos en el entorno de sandbox, por lo que podemos verificar que el código funcione como se espera. Una vez registrado el dominio, veremos detalles sobre él. El siguiente paso es configurar los registros DNS. Probaré con un dominio diferente y lo registraré en el entorno de sandbox para asegurarme de que funcione. Luego, haré lo mismo en producción. Si deseas obtener más información sobre nuestros otros clientes y lo que puedes hacer con la API de DNSimple, visita dnsimple.com/API.

Ahora tenemos el nombre de dominio y el ID del registrante. Ten en cuenta que todavía estamos en el entorno de sandbox, por lo que podemos registrar nombres de dominio que en realidad no se registrarán, pero podemos verificar que el código funcione como se espera en un entorno algo real. Una vez registrado el dominio, veremos algunos detalles sobre él, incluido si las renovaciones automáticas están habilitadas, quién tiene privacidad activada, así como la fecha de creación. El siguiente paso ahora que tenemos un nombre de dominio registrado es configurar los registros DNS para él. Así que voy a configurar un registro de alias que apunte a un sitio web de Webflow que configuré anteriormente. También agregaré una entrada de redireccionamiento de correo electrónico para redirigir a Anthony en mi dominio a otra dirección de correo electrónico, que es mi dirección de correo electrónico de dnsimple.com, y finalmente voy a listar los registros para que podamos ver que todos se crearon. Ahora voy a probar con un dominio diferente y voy a registrarlo en el entorno de sandbox nuevamente para poder ver que funcione como se espera. Una vez registrado el dominio, verás los registros DNS que se acaban de crear también. Y ahora vamos a hacer esto en producción, así que voy a eliminar la URL base, he actualizado mi token y voy a ejecutar este mismo script en nuestro entorno de producción con el dominio que quiero registrar, flammableapp.com. Voy a usar el nuevo ID del registrante para el registrante que está en producción y como puedes ver, sucede lo mismo una vez registrado el dominio, veremos la información DNS sobre él. Y ahora, si entro y abro el dominio, puedes ver que está registrado dentro de dnsimple.com y puedo abrir el dominio en un navegador e ir directamente al sitio web que creé anteriormente en Webflow y puedes ver que el dominio personalizado funciona como se espera. Espero que hayas disfrutado esta charla sobre la API de DNSimple. Si deseas obtener más información sobre nuestros otros clientes y lo que puedes hacer con la API de DNSimple, visita dnsimple.com/API. ¡Que tengas un excelente día!

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Node Congress 2022Node Congress 2022
26 min
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Top Content
Do you know what’s really going on in your node_modules folder? Software supply chain attacks have exploded over the past 12 months and they’re only accelerating in 2022 and beyond. We’ll dive into examples of recent supply chain attacks and what concrete steps you can take to protect your team from this emerging threat.
You can check the slides for Feross' talk here.
React Advanced Conference 2021React Advanced Conference 2021
19 min
Automating All the Code & Testing Things with GitHub Actions
Top Content
Code tasks like linting and testing are critical pieces of a developer’s workflow that help keep us sane like preventing syntax or style issues and hardening our core business logic. We’ll talk about how we can use GitHub Actions to automate these tasks and help keep our projects running smoothly.
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Fine-tuning DevOps for People over Perfection
Top Content
Demand for DevOps has increased in recent years as more organizations adopt cloud native technologies. Complexity has also increased and a "zero to hero" mentality leaves many people chasing perfection and FOMO. This session focusses instead on why maybe we shouldn't adopt a technology practice and how sometimes teams can achieve the same results prioritizing people over ops automation & controls. Let's look at amounts of and fine-tuning everything as code, pull requests, DevSecOps, Monitoring and more to prioritize developer well-being over optimization perfection. It can be a valid decision to deploy less and sleep better. And finally we'll examine how manual practice and discipline can be the key to superb products and experiences.
Node Congress 2022Node Congress 2022
34 min
Out of the Box Node.js Diagnostics
In the early years of Node.js, diagnostics and debugging were considerable pain points. Modern versions of Node have improved considerably in these areas. Features like async stack traces, heap snapshots, and CPU profiling no longer require third party modules or modifications to application source code. This talk explores the various diagnostic features that have recently been built into Node.
You can check the slides for Colin's talk here. 

Workshops on related topic

Node Congress 2023Node Congress 2023
109 min
Node.js Masterclass
Top Content
Workshop
Have you ever struggled with designing and structuring your Node.js applications? Building applications that are well organised, testable and extendable is not always easy. It can often turn out to be a lot more complicated than you expect it to be. In this live event Matteo will show you how he builds Node.js applications from scratch. You’ll learn how he approaches application design, and the philosophies that he applies to create modular, maintainable and effective applications.

Level: intermediate
JSNation 2023JSNation 2023
104 min
Build and Deploy a Backend With Fastify & Platformatic
WorkshopFree
Platformatic allows you to rapidly develop GraphQL and REST APIs with minimal effort. The best part is that it also allows you to unleash the full potential of Node.js and Fastify whenever you need to. You can fully customise a Platformatic application by writing your own additional features and plugins. In the workshop, we’ll cover both our Open Source modules and our Cloud offering:- Platformatic OSS (open-source software) — Tools and libraries for rapidly building robust applications with Node.js (https://oss.platformatic.dev/).- Platformatic Cloud (currently in beta) — Our hosting platform that includes features such as preview apps, built-in metrics and integration with your Git flow (https://platformatic.dev/). 
In this workshop you'll learn how to develop APIs with Fastify and deploy them to the Platformatic Cloud.
Node Congress 2023Node Congress 2023
63 min
0 to Auth in an Hour Using NodeJS SDK
WorkshopFree
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool.
We will enhance a full-stack JS application (Node.JS backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:- User authentication - Managing user interactions, returning session / refresh JWTs- Session management and validation - Storing the session for subsequent client requests, validating / refreshing sessions
At the end of the workshop, we will also touch on another approach to code authentication using frontend Descope Flows (drag-and-drop workflows), while keeping only session validation in the backend. With this, we will also show how easy it is to enable biometrics and other passwordless authentication methods.
Table of contents- A quick intro to core authentication concepts- Coding- Why passwordless matters
Prerequisites- IDE for your choice- Node 18 or higher
JSNation Live 2021JSNation Live 2021
156 min
Building a Hyper Fast Web Server with Deno
WorkshopFree
Deno 1.9 introduced a new web server API that takes advantage of Hyper, a fast and correct HTTP implementation for Rust. Using this API instead of the std/http implementation increases performance and provides support for HTTP2. In this workshop, learn how to create a web server utilizing Hyper under the hood and boost the performance for your web apps.
React Summit 2023React Summit 2023
88 min
Deploying React Native Apps in the Cloud
WorkshopFree
Deploying React Native apps manually on a local machine can be complex. The differences between Android and iOS require developers to use specific tools and processes for each platform, including hardware requirements for iOS. Manual deployments also make it difficult to manage signing credentials, environment configurations, track releases, and to collaborate as a team.
Appflow is the cloud mobile DevOps platform built by Ionic. Using a service like Appflow to build React Native apps not only provides access to powerful computing resources, it can simplify the deployment process by providing a centralized environment for managing and distributing your app to multiple platforms. This can save time and resources, enable collaboration, as well as improve the overall reliability and scalability of an app.
In this workshop, you’ll deploy a React Native application for delivery to Android and iOS test devices using Appflow. You’ll also learn the steps for publishing to Google Play and Apple App Stores. No previous experience with deploying native applications is required, and you’ll come away with a deeper understanding of the mobile deployment process and best practices for how to use a cloud mobile DevOps platform to ship quickly at scale.