Home Reference Source Repository

Function

Static Public Summary
public

afterDelete(recordType: *, func: *, options: {})

public

afterSave(recordType: *, func: *, options: {})

public

beforeDelete(recordType: *, func: *, options: {})

public

beforeSave(recordType: *, func: *, options: {})

public

every(cron: *, func: *, options: {})

public

fromJSON(attrs: *): *

public

handler(path: string, func: function(request: *): object, options: object)

You can configure the cloud code as an HTTP handler, which can respond to requests coming from outside the SDK.

public

hook(name: *, func: *, options: {})

public
public

op(name: *, func: *, options: {})

public

toJSON(v: *): *

Static Public

public afterDelete(recordType: *, func: *, options: {}) source

import {afterDelete} from 'skygear/lib/cloud/index.js'

Params:

NameTypeAttributeDescription
recordType *
func *
options {}
  • optional
  • default: {}

public afterSave(recordType: *, func: *, options: {}) source

import {afterSave} from 'skygear/lib/cloud/index.js'

Params:

NameTypeAttributeDescription
recordType *
func *
options {}
  • optional
  • default: {}

public beforeDelete(recordType: *, func: *, options: {}) source

import {beforeDelete} from 'skygear/lib/cloud/index.js'

Params:

NameTypeAttributeDescription
recordType *
func *
options {}
  • optional
  • default: {}

public beforeSave(recordType: *, func: *, options: {}) source

import {beforeSave} from 'skygear/lib/cloud/index.js'

Params:

NameTypeAttributeDescription
recordType *
func *
options {}
  • optional
  • default: {}

public every(cron: *, func: *, options: {}) source

import {every} from 'skygear/lib/cloud/index.js'

Params:

NameTypeAttributeDescription
cron *
func *
options {}
  • optional
  • default: {}

public fromJSON(attrs: *): * source

import {fromJSON} from 'skygear/lib/util.js'

Params:

NameTypeAttributeDescription
attrs *

Return:

*

public handler(path: string, func: function(request: *): object, options: object) source

import {handler} from 'skygear/lib/cloud/index.js'

You can configure the cloud code as an HTTP handler, which can respond to requests coming from outside the SDK. A custom HTTP endpoint can be created using the handler function.

A custom HTTP endpoint can be useful for the followings:

  • receiving requests from outside the Skygear SDK
  • allowing a third party webhook to call upon (e.g. payment service)

Params:

NameTypeAttributeDescription
path string

The path of the handler to be mount.

func function(request: *): object

function to be registered.

options object
  • optional

options for setting method, userRequired and keyRequired.

Example:

const skygearCloud = require('skygear/cloud');¬
skygearCloud.handler('handler1', function(req) {
    // cloud code handling the request
    return 'String';
}, {
    method: ['GET', 'POST'],
    userRequired: false
});
skygearCloud.handler('private', function(req) {
    // cloud code handling the request
    return {
      status: 'ok'
    };
}, {
    method: ['GET', 'POST'],
    userRequired: true
});

public hook(name: *, func: *, options: {}) source

import {hook} from 'skygear/lib/cloud/index.js'

Params:

NameTypeAttributeDescription
name *
func *
options {}
  • optional
  • default: {}

public isLocalStorageValid(): boolean source

import {isLocalStorageValid} from 'skygear/lib/util.js'

Return:

boolean

public op(name: *, func: *, options: {}) source

import {op} from 'skygear/lib/cloud/index.js'

Params:

NameTypeAttributeDescription
name *
func *
options {}
  • optional
  • default: {}

public toJSON(v: *): * source

import {toJSON} from 'skygear/lib/util.js'

Params:

NameTypeAttributeDescription
v *

Return:

*