UNPKG

sls-helper-plugin-janis

Version:

A Serverless Helper plugin to add custom helpers for Janis Commerce

28 lines (22 loc) 471 B
'use strict'; const { inspect } = require('util'); const buildCors = require('../utils/cors'); module.exports = ({ custom, ...serviceConfig }, corsConfig) => { if(corsConfig === false) { return { ...serviceConfig, custom }; } try { return { ...serviceConfig, custom: { ...(custom || {}), cors: buildCors(corsConfig) } }; } catch(e) { throw new Error(`Missing or invalid config in janis.cors hook: ${inspect(corsConfig)}`); } };