在无服务器环境中编译handler.js时Javscript语法错误

时间:2018-09-25 07:32:44

标签: serverless

我正在尝试使用Serverless来编译后端文件。 “ ...”似乎正在引起错误,但我不知道为什么。

./ handler.js中的错误 模块构建失败:SyntaxError:” /handler.js:意外令牌(27:6)

const customContext = { ...上下文 ^ 用户:{ ID, 类型:isGuest? USER_TYPE.GUEST:USER_TYPE.USER,

Below is the full code in handler.js file

// console.log('graphql - event:', JSON.stringify(event));
if (event.source === 'aws.events') {
  return callback(null, createResponse(200, ''));
}

const {body, requestContext = {}, headers } = event;
const bodyObj = JSON.parse(body);

/* BEGIN: build custom context from event object */
const identity = requestContext.identity;
if (!identity) {
  // noinspection ExceptionCaughtLocallyJS
  throw new Error('---- Missing identity in requestContext');
}

const isGuest = (identity.cognitoAuthenticationType == 'unauthenticated');
const id = isGuest ? identity.cognitoAuthenticationType : getIdHelper(requestContext);

  const customContext = {
      ...context,
      user: {
          id, type: isGuest ? USER_TYPE.GUEST : USER_TYPE.USER,
      },
      identity,
      headers
  };

0 个答案:

没有答案