Atlassian Connect Shelf Server


Provides a server based on the Shelf library.

It includes the following Shelf Middleware components:

  • productHostAuthenticator. A Shelf Middleware component for authenticating requests from product hosts
  • sessionTokenAuthenticator. A Shelf Middleware component for authenticating requests from the addon client code using the Atlassian Connect session token mechanism

In addition it includes:

  • AcDartRouteBuilder. A builder for creating routes using the Shelf Route library
  • startServer. A helper function for starting the Shelf http server

The Shelf Server uses all the other Atlassian Connect Dart libraries. It's the easiest way to get started and we believe provides a good solution. However, if you prefer another web framework then you can still use all the other Atlassian Connect Dart libraries, greatly reducing the effort to get up and running.


Basic Usage

Note there is an example project that is in the example folder of the library that illustrates basic usage.

Create your Configuration

See the documentation for the Atlassian Connect Configuration library for details.

Define your Routes

Implement a function with the following signature

typedef RouteInitialiser(AcDartRouteBuilder routeBuilder, String addonKey, Uri addonBaseUri);

For example

void initRoutes(AcDartMainRouteBuilder routeBuilder, String addonKey, Uri addonBaseUri) {
      m.moustacheFile('../ui/exampleUI.html', includeExtraParams: true), 
      '/ui/exampleUI.html', method: 'GET');  

  routeBuilder.addHostServiceSessionTokenRoute(_fetchJiraIssue, '/issue/{$_ISSUE_KEY}');

This adds routes to handle the installation lifecycle event and to serve the atlassian-connect.json descriptor from a moustache template, in both cases using default values for url etc. Note these values are overrideable.

It also adds:

  • one route for serving request received from a host (e.g. from a web item) from /ui/exampleUI.html. This page will served with an addon session token and contains JavaScript to make a REST call back the addon host at /issue/{$_ISSUE_KEY}
  • one route to serve the REST requests from the addon client (in /ui/exampleUI.html).

Start Your Engines

Now you can fire up the server

void main() {
  startServer(initRoutes, config);

And away you go.