index.js
function createEndpointFromObject(path, query, body) {
  // OPTIONS gives server permission to use CORS
  server.createRoute({
    request: {
        url: path,
        query: query || {},
        method: 'options',
    },
    response: {
        code: 200,
        delay: config.latency,
        body: {},
        headers: {
          'Access-Control-Allow-Origin': config.allowOrigin,
          // allow several methods since some endpoints are writable
          'Access-Control-Allow-Methods': 'GET, PUT, POST',
          'Access-Control-Allow-Credentials': 'true'
        }
    }
  });
  return server.get(path)
               .query(query)
               .responseHeaders({
                 'Access-Control-Allow-Origin': config.allowOrigin,
                 'Access-Control-Allow-Methods': 'GET, PUT, POST',
                 'Access-Control-Allow-Credentials': 'true'
               })
               .body(body)
               .delay(config.latency);
}
function createEndpointFromObject(path, query, body) {
  // OPTIONS gives server permission to use CORS
  server.createRoute({
    request: {
        url: path,
        query: query || {},
        method: 'options',
    },
    response: {
        code: 200,
        delay: config.latency,
        body: {},
        headers: {
          'Access-Control-Allow-Origin': config.allowOrigin,
          // allow several methods since some endpoints are writable
          'Access-Control-Allow-Methods': 'GET, PUT, POST',
          'Access-Control-Allow-Credentials': 'true'
        }
    }
  });
  return server.get(path)
               .query(query)
               .responseHeaders({
                 'Access-Control-Allow-Origin': config.allowOrigin,
                 'Access-Control-Allow-Methods': 'GET, PUT, POST',
                 'Access-Control-Allow-Credentials': 'true'
               })
               .body(body)
               .delay(config.latency);
}
function createEndpointFromObject ( path , query , body ) { // OPTIONS gives server permission to use CORS server . createRoute ( { request : { url : path , query : query || { } , method : 'options' , } , response : { code : 200 , delay : config . latency , body : { } , headers : { 'Access-Control-Allow-Origin' : config . allowOrigin , // allow several methods since some endpoints are writable 'Access-Control-Allow-Methods' : 'GET, PUT, POST' , 'Access-Control-Allow-Credentials' : 'true' } } } ) ; return server . get ( path ) . query ( query ) . responseHeaders ( { 'Access-Control-Allow-Origin' : config . allowOrigin , 'Access-Control-Allow-Methods' : 'GET, PUT, POST' , 'Access-Control-Allow-Credentials' : 'true' } ) . body ( body ) . delay ( config . latency ) ; }
Registers an endpoint using the given response body.
Registers an endpoint using the given response body .