DADI Web, first install

Web is the front-end component within the DADI web services stack, useful when you want serve any web document – HTML, CSS, JSON & XML etc.

Web is the front-end component within the DADI web services stack, useful when you want serve any web document – HTML, CSS, JSON & XML etc.

There are three ways to get started with Web, each for slightly different situations.

N.B. Most DADI web services require Node.js and NPM – and I’ll assume you have a basic knowledge of these.

🔗1. DADI CLI - Least hassle

Image

DADI CLI (Command line interface) is by far the simplest way. Once you’ve installed it, CLI will help install, update and customise all DADI Web Services.

Eduardo Bouças has covered this in a previous article, but we’ll do a quick overview again here.

Assuming you haven’t already installed the CLI. Run the following command in your terminal:

npm install @dadi/cli -g

This gives you a world of possibilities across our services. Run dadi in your terminal to see the full list.

Ok, now we can install Web. Firstly, create and/or cd into your project directory and run:

dadi web new

CLI will ask you some questions to automate the installation, including which template engine you would like to run.

We recommend Dust.js if this is your first time getting into Javascript-based template engines. Those familiar with ES6 will find this engine the simplest to get started.

You can learn more about template engines in our documentation.

🔗2. NPM - Slightly more hassle, more up-front customisation

If you’re already up and running using NPM to manage dependencies you just need to install the Web package in your project:

npm i @dadi/web

N.B. As of NPM 5.0, --save is on by default so the package will be added to your package.json file automatically.

Sadly, you don’t quite have enough here to start the app just yet. For that you’ll need to grab the latest workspace from our registry. Or create the following files:

server.js

require('@dadi/web')({engines:\[require('@dadi/web-dustjs')\]})

Web comes with our Dust.js engine by default.

/config/config.development.json

{
  "cluster": false,
  "allowJsonView": true,
  "debug": true
}

You can check out the full configuration options in the docs.

/workspace/pages/index.json

{
  "page": {
    "key": "index"
  }
}

/workspace/pages/index.dust

This page is powered by DADI Web {version}

You can now run the start command, and all being well you should have a site viewable at http://localhost:8080/

npm start

🔗3. Download - Hackers and contributors

Using NPM keeps the nuts and bolts hidden away in your node_modules folder, but for some smaller self-contained projects, or if you want to contribute to the development of Web you’ll need to grab the source directly from our Github repository.

The default branch across all DADI services is develop where we’re busy merging in new features for the next release, but if you need stability, check out the releases page. You can also see a detailed notes for each release here.

P.S. We’ve written a complete guide to contributing to Web and we’re happy to receive new issues or pull requests :)

Assuming you’ve download a zip of the develop branch (web-develop.zip) you’ll first want to install Web’s dependencies:

cd ./web-develop
npm i

Good luck! Any questions? Find us on Discord.

Related articles

More tutorials articles
Mail icon

Like what you are reading? Want to earn tokens by becoming a DADI Node? Save money on cloud computing services? Build amazing digital product with DADI Web Services? Join our mailing list.

To hear about our news, events and products or services subscribe now. You can also indicate which services you are interested in, which we use for research and to inform the content that we send generally.

* You can unsubscribe at any time by emailing us at data@dadi.cloud or by clicking on the unsubscribe link which can be found in our emails to you. Read our Privacy Policy.