npm installbower installcp application/config.dist.js application/config.jsnpm install -g webpacknpm startto build the app and launch a server atlocalhost:9000- Use
npm run windowsto build and launch the app on Windows
- Use
The top level configuration for Lively is stored at application/config.js. An example is provided in application/config.dist.js and below:
{
lively : {
hostname : 'localhost',
port : 9001
},
apis : {
github : require('./config/config.github')
}
}A summary and logo can be associated with an API using the assets file at application/assets.js. An example is provided in application/assets.dist.js and below:
{
apis : {
github : {
logo : require('../media/images/logos/github-mark.png'),
summary : require('./config/github/summary.md')
}
}
}- logo: A
stringcontaining a valid path to an image to display for the logo - summary: A
stringcontaining the summary that will be displayed by default when you click on an API
Note that PNG and Markdown files can be required directly, thanks to Webpack's file and markdown loaders.
The application is initialized with an empty assets file by default, in the case that no assets exist.
The lively configuration block defines the app's behavior.
- hostname: A
stringcontaining the hostname where Lively will be installed - port: An
integercontaining the port for Lively to listen on
The apis configuration block tells Lively where to find configuration files for the APIs you want to use with it. The recommended structure for these is to create folders in application/config for each API and use require() to include them (see example above).
Each API has a configuration that tells Lively how to make requests and what endpoints are available. An example of implementing an API configuration for GitHub is provided at application/config/config.github.js.
{
'name' : 'GitHub v3 API',
'api' : {
'hostname' : 'api.github.com',
'port' : 443,
'secure' : true
},
'oauth2' : {
'type' : 'authorization-code',
'hostname' : 'github.com',
'port' : 443,
'secure' : true,
'authorizeUrl' : '/login/oauth/authorize',
'tokenUrl' : '/login/oauth/access_token',
'tokenParam' : 'token'
},
'resources' : [
require('./github/activity'),
require('./github/gists'),
require('./github/git_data'),
{...}
]
}
- name: A
stringcontaining the display name for the API. - api: An
Objectcontaining connection details for API calls (see below) - oauth2: An
Objectcontaining the connection and authentication information for OAuth2 APIs (see below) - resources: An array of
Objectcontaining a resource configuration object for each resource. Resources can be nested arbitrarily deep, see the resource configuration section for more details. The recommended structure is to create folders for each top level resource inside your API configuration folder.
- hostname: A
stringcontaining the hostname of the API server - port: An
integercontaining the port of the API server - secure: A
bool(trueorfalse) that determines whether HTTPS is used
- type: A
stringcontaining the string 'authorization-code' - hostname: A
stringcontaining the hostname of the OAuth2 server - port: An
integercontaining the port of the OAuth2 server - secure: A
bool(trueorfalse) that determines whether HTTPS is used - authorizeUrl: A
stringcontaining the path to the OAuth2 authorization endpoint, which will be appended to the hostname - tokenUrl: A
stringcontaining the path to the OAuth2 access token endpoint, which will be appended to the hostname. - tokenParam: A
stringrepresenting the argument given in the Authorization header, some APIs (including GitHub) need this overridden. Default:Bearer
An API is made up of multiple resources. Each resource has a list of endpoints that can be called on it. There are many example resources provided with the GitHub API configuration.
{
name : 'Activity',
slug : 'activity',
synopsis : 'This is a read-only API to the GitHub events.',
endpoints : [
{...},
{...}
],
resources : [
{...},
{...}
]
}
- name: A
stringcontaining the display name of this resource - slug: A
stringcontaining the slug for this resource's URL. If this is left undefined, a slugified version ofnamewill be used instead. - synopsis: A
stringcontaining the static text to be displayed on the resource page. This can be used for static pages (for example, a category description) or to display a short summary for endpoints. If this is left undefined, no synopsis will be displayed. - endpoints: An array of
Objectcontaining endpoint objects to display on the page. See below for more on defining endpoints. If no endpoints are given, no endpoints will be displayed. - resources: An array of
Objectcontaining additional resources which will nest below this one. Resources may be nested arbitrarily deep but the recommendation is to not go below a depth of 3.
{
name : 'List repository events',
synopsis : 'This endpoint lists repository events',
method : 'GET',
uri : '/repos/:owner/:repo/events',
oauth : false,
bodyType : 'json-object',
params : [
{
name : 'owner',
required : true,
type : 'string',
location : 'uri', // This tells Lively to match :owner in the endpoint's URI
description : 'The owner of the repo.'
},
{...}
]
}
- name: A
stringcontaining the display name of this endpoint - synopsis: A
stringcontaining the static text to be displayed in the endpoint dropdown. If this is left undefined, no synopsis will be displayed. - method: A
stringcontaining the HTTP method to be used for the request. - uri: A
stringcontaining the path of the endpoint. Parts that are prefixed with:will be filled in by theparamwith the same name and itslocationset touri. See below for more details onparams. - oauth: A
bool(trueorfalse) which determines whether or not this request defaults to using oauth or unauthenticated. - bodyType: A
stringcontaining the body type the request should contain. Default isjson-object, only alternate at this time isjson-param, which will use the contents of the remaining bodyparamas the request body. - rootParam: A
stringcontaining the name of the parameter which will be used as the body request. This option is only available whenbodyType = 'json-param'. - params: An array of
Objectcontaining parameter objects which this endpoint can accept. See below for details.
string example:
{
name : 'owner',
required : true,
type : 'string',
location : 'uri',
defaultValue : 'synapsestudios',
description : 'The owner of the repo.'
}
object example:
{
name : 'thing',
required : true,
type : 'object',
description : 'a set of properties defining a thing.',
params : [
{
name : 'owner',
required : true,
type : 'string',
defaultValue : 'synapsestudios',
description : 'The owner of the repo.'
}
]
}
array example:
{
name : 'owners',
required : true,
type : 'array',
location : 'An array of owners.',
param : {
name : 'owner',
type : 'string',
defaultValue : 'synapsestudios',
description : 'The owner of the repo.'
}
}
- name: A
stringcontaining the key or name of this parameter that will be sent in the request body or injected into the URI. - required: A
bool(trueorfalse) which flags this parameter as required.requiredis not used in anarrayparameter as they may just be removed. - type: A
stringcontaining one of:string,integer,float,checkbox,boolean,resumable-upload,object,array,stripe_token,custom-object, orenum.objectwill require a child set ofparams, defined like a top-level list of params. Anobjectparam'slocationmust be "body" and should not be used inGETrequests.arraywill require a childparam, which is a single object (see example)custom-objectwill allow the user to create objects with arbitrary keys and values, including child objects.- If
enum, specifyenumValuesproperty on param containing an array of strings to display as options to the user.
- location: A
stringcontaining one ofheader,body,uriorquery. If the param is named in the endpoint's URI, Lively will ignore the stated location. Default:bodyunless param is named in URI, thenuri. - defaultValue: A
string,bool, orarraydepending on whattypeis set. The default value to display in the param. - description: A
stringcontaining a short description of the parameter.