sls-helper-plugin-janis
Advanced tools
Comparing version 2.8.0 to 2.9.0-alpha.0
@@ -19,2 +19,15 @@ 'use strict'; | ||
const apiPathPartToName = apiPathPart => apiPathPart | ||
.replace(/-/g, 'Dash') | ||
.replace(/\{(.+)\}/, '$1Var') | ||
.replace(/[^0-9A-Za-z]/g, '') | ||
.replace(/^./, firstChar => firstChar.toUpperCase()); | ||
const apiPathToName = apiPath => apiPath | ||
.split('/') | ||
.map(apiPathPart => apiPathPartToName(apiPathPart)) | ||
.join(''); | ||
const getFunctionName = (method, apiPath) => `${startcase(method)}${apiPathToName(apiPath)}`; | ||
const apiBase = ({ | ||
@@ -68,3 +81,6 @@ path, | ||
const functionName = getFunctionName(methodName, normalizedPath); | ||
const functionConfiguration = { | ||
name: `API-\${self:custom.serviceName}-${functionName}-\${self:custom.stage}`, | ||
handler: handler || 'src/lambda/RestApi/index.handler', | ||
@@ -92,7 +108,4 @@ description, | ||
const apiName = startcase(`${fileDir}-${methodName}-api`).replace(/ /g, ''); | ||
return { | ||
[apiName]: | ||
functionConfiguration | ||
[`API-${functionName}`]: functionConfiguration | ||
}; | ||
@@ -99,0 +112,0 @@ }; |
@@ -13,2 +13,13 @@ 'use strict'; | ||
const getFunctionNamePrefix = methodName => { | ||
switch(methodName.toLowerCase()) { | ||
case 'post': | ||
return 'Create'; | ||
case 'put': | ||
return 'Update'; | ||
default: | ||
return startcase(methodName); | ||
} | ||
}; | ||
const apiBase = ({ | ||
@@ -66,2 +77,3 @@ entityName, | ||
const functionConfiguration = { | ||
name: `API${getFunctionNamePrefix(methodName)}-\${self:custom.serviceName}-${entityNameAsTitle.replace(/ /g, '')}-\${self:custom.stage}`, | ||
handler: handler || 'src/lambda/RestApi/index.handler', | ||
@@ -90,3 +102,5 @@ description: `${entityNameAsTitle} ${startcase(methodName)} API`, | ||
return { [`${entityNameAsTitle.replace(/ /g, '')}${startcase(methodName)}Api`]: functionConfiguration }; | ||
return { | ||
[`API${getFunctionNamePrefix(methodName)}-${entityNameAsTitle.replace(/ /g, '')}`]: functionConfiguration | ||
}; | ||
}; | ||
@@ -93,0 +107,0 @@ |
@@ -31,5 +31,6 @@ 'use strict'; | ||
const listenerName = `${serviceNameAsTitle}${entityNameAsTitle}${eventNameAsTitle}Listener`.replace(/ /g, ''); | ||
const listenerCode = `${serviceNameAsTitle}${entityNameAsTitle}${eventNameAsTitle}`.replace(/ /g, ''); | ||
const functionConfiguration = { | ||
name: `EL-\${self:custom.serviceName}-${listenerCode}-\${self:custom.stage}`, | ||
handler: `src/${listenersDirName}/${serviceAsKebab}/${entityNameAsKebab}/${eventNameAsKebab}.handler`, | ||
@@ -58,3 +59,3 @@ description: `${serviceNameAsTitle} ${entityNameAsTitle} ${eventNameAsTitle} Listener`, | ||
return { | ||
[listenerName]: functionConfiguration | ||
[`EL-${listenerCode}`]: functionConfiguration | ||
}; | ||
@@ -61,0 +62,0 @@ }; |
{ | ||
"name": "sls-helper-plugin-janis", | ||
"version": "2.8.0", | ||
"version": "2.9.0-alpha.0", | ||
"description": "A Serverless Helper plugin to add custom helpers for JANIS Commerce", | ||
@@ -5,0 +5,0 @@ "main": "lib/plugin.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37754
867
1