Skip to content

Version 2.0.0

Compare
Choose a tag to compare
@jimlambie jimlambie released this 24 Apr 09:59
· 689 commits to master since this release

Breaking changes

DADI API connection disabled by default

You now have to explicitly set the API config block to be enabled, previous versions assumed this value was true if not present in the configuration file. If connecting Web to a DADI API, the configuration file must now contain api settings similar to the following:

"api": {
  "enabled": true,
  "host": "127.0.0.1",
  "port": 8080
}

Datasource type dadiapi replaces remote

Previous to 2.0 the datasource source type for connecting to a DADI API was called remote. This has changed to dadiapi to ensure clarity with the updated and repurposed Remote provider.

A typical datasource specification file would now contain the following:

"source": {
  "type": "dadiapi",
  "endpoint": "1.0/articles"
}

The default is dadiapi, so there is no requirement to specify this property when connecting to a DADI API.

New Features

Default workspace

#133: Web will boot straight out of the box with a default ‘blog’ style configuration and some suggestions of next steps. The site is mobile responsive and uses the new Markdown provider datasource to serve content from the workspace/posts folder.

Better errors

#150, #152: We now have more human readable error messages out the box so your users don’t ever just receive plain JSON back. You can still override them with your own in the normal way.

Inject request parameters into datasource endpoints

You can now pass requestParams to a datasource endpoint's URL by specifying a new setting "target": "endpoint". The param value will be injected into a placeholder in the URL identified by the field value. For example:

{
  "datasource": {
    "key": "instagram",
    "source": {
      "type": "remote",
      "protocol": "http",
      "host": "instagram.com",
      "endpoint": "{userPlaceholder}/?__a=1"
    },
    "auth": false,
    "requestParams": [
      {
        "param": "user", // from the request parameters, e.g. http://www.example.com/profile/:user
        "field": "userPlaceholder",
        "target": "endpoint"
      }
    ]
  }
}

Post install

After running npm install Web will now create default workspace and config folders in your project directory. A server.js file will also be created which will let you boot the app immediately by running npm start.

The script will not overwrite existing workspace or config folders, or an existing server.js file.

Data Providers

Remote Provider

Connect to a miscellaneous API via HTTP or HTTPS. See the following file as an example: workspace/datasources/instagram.json

Markdown Provider

Serve content from a local folder containing text files. You can specify also specify the extension to grab. Web will process any Markdown formatting (with Marked) it finds automatically as well as any Jekyll-style front matter found. Any dates/times found will be processed through JavasScript’s Date() function.

{
  "datasource": {
    "source": {
      "type": "markdown",
      "path": "./workspace/posts",
      "extension": "md"
    }
  }
}

workspace/posts/somefolder/myslug.md

---
date: 2016-02-17
title: Your title here
---
Some *markdown*

When loaded becomes the following data:

{
  "attributes": {
    "date": "2016-02-17T00:00:00.000Z",
    "title": "Your title here",
    "_id": "myslug",
    "_ext": ".md",
    "_loc": "workspace/posts/somefolder/myslug.md",
    "_path": [
      "somefolder"
    ]
  },
  "original": "---\ndate: 2016-02-17\ntitle: Your title here\n---\nSome *markdown*",
  "contentText": "Some *markdown*",
  "contentHtml": "<p>Some <em>markdown</em></p>\n"
}

NB. _path will exclude the datasource source.path.

Virtual Hosts

DADI Web can now serve content to multiple hostnames from a single installation. Only certain configuration options can be modified for each hostname; these are currently restricted to paths (for pages/partials/datasources/etc) and global.

"virtualHosts": {
  "one": {
    "hostnames": ["domain1.dev"],
    "configFile": "one.qa.json",
    "default": true
  },
  "two": {
    "hostnames": ["domain2.dev"],
    "configFile": "two.qa.json"
  }
}

Changed

  • #128: attach compression middleware prior to static middleware
  • #130: leave url params unmodified when lowercasing urls
  • #139 remove datasource path from attributes
  • #144: check host header against specified hosts before serving static files
  • don’t modify original schema endpoint (4901ecc)
  • rename sample-workspace to workspace (c307b8e)