API Docs for: 0.8.0
Show:

SiteService Class

Service for performing site specific operations.

Constructor

Methods

activateSite

(
  • siteUid
  • cb
)
String

Run a job to activate a site so that all of its routes are available.

Parameters:

  • siteUid String
    • site unique id
  • cb Function
    • callback to run after job is completed

Returns:

String:

the job id

areEqual

(
  • siteA
  • siteB
)
Boolean

Returns true if both site ids given are equal

Parameters:

  • siteA String
    • first site id to compare
  • siteB String
    • second site id to compare

Returns:

Boolean:

true if equal, false otherwise

createSite

(
  • options
  • cb
)

Creates a site and saves it to the database.

Parameters:

  • options Object
    • object containing site fields
    • hostname String
      • result of site hostname edit/create
    • displayName String
      • result of site display name edit/create
  • cb Function
    • callback function

deactivateSite

(
  • siteUid
  • cb
)
String

Run a job to set a site inactive so that only the admin routes are available.

Parameters:

  • siteUid String
    • site unique id
  • cb Function
    • callback to run after job is completed

Returns:

String:

the job id

deleteSiteSpecificContent

(
  • siteId
  • cb
)

Parameters:

  • siteId String
  • cb Function

editSite

(
  • options
  • cb
)
String

Run a job to update a site's hostname and/or displayname.

Parameters:

  • options Object
    • object containing site fields
    • uid String
      • site uid
    • hostname String
      • result of site hostname edit/create
    • displayName String
      • result of site display name edit/create
  • cb Function
    • callback to run after job is completed

Returns:

String:

the job id

getActiveSites

(
  • cb
)

Get all site objects where activated is true.

Parameters:

  • cb Function
    • the callback function

getAllSites

(
  • cb
)

Get all of the site objects in the database

Parameters:

  • cb Function
    • the callback function

getByUid

(
  • uid
  • cb
)

Load full site config from the database using the unique id.

Parameters:

  • uid String
    • unique id of site
  • cb Function
    • the callback function

getCurrentSite

(
  • siteid
)
String

Central place to get the current site. Backwards compatible cleansing

Parameters:

  • siteid String
    • site is to cleanse

Returns:

String:

SiteService.GLOBAL_SITE if not specified, or siteid otherwise

getExistingDisplayNameHostnameCounts

(
  • displayName
  • hostname
  • id
  • cb
)

Gets the total counts of a display name and hostname in the site collection

Parameters:

  • displayName String
    • site display name
  • hostname String
    • site hostname
  • id String
    • Site object Id to exclude from the search
  • cb Function
    • Callback function

getGlobalSiteContext

() Object static

Retrieves the global site context

Returns:

Object:

getHostWithProtocol

(
  • hostname
)
String

Determine whether http or https is being used for the site and return hostname attached to http(s)

Parameters:

  • hostname String

Returns:

String:

hostname with protocol attached

getInactiveSites

(
  • cb
)

Get all site objects where activated is false.

Parameters:

  • cb Function
    • the callback function

getSiteFromObject

(
  • object
)
String

Return site field from object.

Parameters:

  • object Object

Returns:

String:

the value of the object's site field key

getSiteMap

(
  • cb
)

Get all site objects segmented by active status.

Parameters:

  • cb Function
    • the callback function

getSiteNameByUid

(
  • uid
  • cb
)

Get site name given a unique id.

Parameters:

  • uid String
    • unique id
  • cb Function
    • the callback function

init

() static

Register activate and deactivate commands on initialization

initSites

(
  • cb
)

Load all sites into memory.

Parameters:

  • cb Function

isDisplayNameOrHostnameTaken

(
  • displayName
  • hostname
  • id
  • cb
)

Checks to see if a proposed site display name or hostname is already in the system

Parameters:

  • displayName String
    • desired name to display
  • hostname String
    • hostname of the site
  • id String
    • Site object Id to exclude from the search
  • cb Function
    • Callback function

isGlobal

(
  • siteId
)
Boolean

Returns true if siteId given is global or non-existent (to remain backwards compatible)

Parameters:

  • siteId String
    • the site id to check

Returns:

Boolean:

true if global or does not exist

isNotSetOrEqual

(
  • actual
  • expected
)
Boolean

Returns true if actual is not set (falsey) or logically equivalent to expected in terms of sites

Parameters:

  • actual String
    • site to check
  • expected String
    • site you expect to be equal

Returns:

Boolean:

true if actual exists and equals expected

onActivateSiteCommandReceived

(
  • command
)
static

Runs a site activation job when command is received.

Parameters:

  • command Object
    • the command to react to.

onCreateEditSiteCommandReceived

(
  • command
)
static

Runs a site deactivation job when command is received.

Parameters:

  • command Object
    • the command to react to.

onDeactivateSiteCommandReceived

(
  • command
)
static

Runs a site deactivation job when command is received.

Parameters:

  • command Object
    • the command to react to.

startAcceptingSiteTraffic

(
  • siteUid
  • cb
)

Given a site uid, activate if the site exists so that user facing routes are on.

Parameters:

  • siteUid String
    • site unique id
  • cb Function
    • callback function

stopAcceptingSiteTraffic

(
  • siteUid
  • cb
)

Given a site uid, deactivate if the site exists so that user facing routes are off.

Parameters:

  • siteUid String
    • site unique id
  • cb Function
    • callback function

Properties

GLOBAL_SITE

String static

represents default configuration, not actually a full site

NO_SITE

String static

represents a site that doesn't exist

SITE_COLL

String private static

SITE_COLLECTION

String static

SITE_FIELD

String static

TYPE

String private static

The name of the DB collection where the resources are persisted