DNSimple platform

The platform

Add-ons: getting started

Add-Ons: Reference

Getting started: Node.js

This tutorial covers how to get the Node.js “Hello Domains” app running on your machine.

Make sure you followed the previous steps, which are common to all languages and technologies.

A note on frameworks: As the Node.js community has a broad varierty of frameworks, we decided to have the hello-domains app and the corresponding getting started guide in plain Node. If you plan on writing your DNSimple add-on in Node, you might want to consider a framework like hapi, Koa, Sails.js, or Express.js.

Installing Node.js

To follow this tutorial you will need a current Node.js version on your system. Instructions on installing Node.js may be found on https://nodejs.org/.

Getting the code

The first step is to clone the hello-domains-node repository from github.

> git clone git@github.com:dnsimple/hello-domains-node.git
Cloning into 'hello-domains-node'...
remote: Counting objects: 27, done.
remote: Total 27 (delta 0), reused 0 (delta 0), pack-reused 27
Receiving objects: 100% (27/27), 5.67 KiB | 0 bytes/s, done.
Resolving deltas: 100% (12/12), done.

You should now have the application source code on your machine. Feel free to take some time and browse through it.

Getting the dependencies

The hello-domains node application has a few dependencies, including the DNSimple Node.js client, that you need to install:

> npm install
hello-domains@0.0.1 ~/projects/hello-domains-node
├─┬ client-sessions@0.7.0
[...]
├─┬ connect@3.4.1
[...]
├── dnsimple@2.4.0
└─┬ randomstring@1.1.5
[...]

Configuring the DNSimple API client

Now that you have the code and its dependencies on your machine you need to configure the app. To do so, copy the example configuration to config.js:

> cp config.example.js config.js

Now set config.clientId and config.clientSecret according to the values you received from DNSimple when you followed the common steps for all languages.

Set config.session.secret to a randomly generated string. You can generate a random string like so:

> openssl rand -hex 32

Copy and then paste it into config.js:

# config.js
config.session.secret = 'somelongrandomstring';

Running the application

> node server.js

Congratulations 🎉, now you should have a working Node.js hello domains add-on running on your machine locally at http://localhost:3000/.

If you encounter any problems please see the Troubleshooting guide.