Blame view

node_modules/strong-remoting/example/documentation/remotes/simple.js 1003 Bytes
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  // Copyright IBM Corp. 2013,2016. All Rights Reserved.
  // Node module: strong-remoting
  // This file is licensed under the Artistic License 2.0.
  // License text available at https://opensource.org/licenses/Artistic-2.0
  
  // This helper adds methods to a module that we assume will be added to the remotes.
  // TODO(schoon) - Make this _the_ API, not a "helper".
  // TODO(schoon) - Document EVERYTHING
  var helper = require('../../../').extend(module.exports);
  
  /**
   * Returns a secret message.
   */
  helper.method(getSecret, {
    returns: { name: 'secret', type: 'string' }
  });
  function getSecret(callback) {
    callback(null, 'shhh!');
  }
  
  /**
   * Takes a string and returns an updated string.
   */
  helper.method(transform, {
    accepts: [{ name: 'str', type: 'string', required: true, description: 'The value to update' }],
    returns: { name: 'str', type: 'string' },
    description: 'Takes a string and returns an updated string.'
  });
  function transform(str, callback) {
    callback(null, 'transformed: ' + str);
  }