Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async deployWebsockets() {
this.init()
await this.prepareFunctions()
if (
!is(Object, this.serverless.service.functions) ||
keys(this.serverless.service.functions).length === 0 ||
isEmpty(this.functions)
) {
return
}
this.serverless.cli.log(`Deploying Websockets API named "${this.apiName}"...`)
await this.createApi()
// We clear routes before deploying the new routes for idempotency
// since we lost the idempotency feature of CF
await this.clearRoutes()
await this.clearAuthorizers()
await this.clearIntegrations()
await this.createAuthorizers()
await this.createRoutes()
await this.createDeployment()
this.serverless.cli.log(
`Websockets API named "${this.apiName}" with ID "${this.apiId}" has been deployed.`
)
async deployWebsockets() {
this.init()
await this.prepareFunctions()
if (
!is(Object, this.serverless.service.functions) ||
keys(this.serverless.service.functions).length === 0 ||
isEmpty(this.functions)
) {
return
}
this.serverless.cli.log(`Deploying Websockets API named "${this.apiName}"...`)
await this.createApi()
// We clear routes before deploying the new routes for idempotency
// since we lost the idempotency feature of CF
await this.clearRoutes()
await this.clearAuthorizers()
await this.clearIntegrations()
await this.createAuthorizers()
await this.createRoutes()
await this.createDeployment()
this.serverless.cli.log(
async defineFunction(functionInstance, context) {
const funcInstance = resolve(functionInstance)
// need to resolve these two variables now to convert values
const ufs = resolve(funcInstance.ufs) || resolve(this.ufs) || false
const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
let code = resolve(funcInstance.code)
const inputs = {
provider: this.provider,
role: this.role,
functionName: funcInstance.functionName,
functionDescription: funcInstance.functionDescription,
memorySize: resolve(funcInstance.memory) || resolve(this.memory),
timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
runtime,
handler: resolve(funcInstance.handler),
environment: {
...resolve(this.environment),
async defineFunction(functionInstance, context) {
const funcInstance = resolve(functionInstance)
// need to resolve these two variables now to convert values
const ufs = resolve(funcInstance.ufs) || resolve(this.ufs) || false
const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
let code = resolve(funcInstance.code)
const inputs = {
provider: this.provider,
role: this.role,
functionName: funcInstance.functionName,
functionDescription: funcInstance.functionDescription,
memorySize: resolve(funcInstance.memory) || resolve(this.memory),
timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
runtime,
handler: resolve(funcInstance.handler),
environment: {
...resolve(this.environment),
...resolve(funcInstance.environment)
},
code,
tags: {
...resolve(this.tags),
...resolve(funcInstance.tags)
}
}
if (ufs) {
code = [code, getShimFile(runtime)]
async defineFunction(functionInstance, context) {
const funcInstance = resolve(functionInstance)
// need to resolve these two variables now to convert values
const ufs = resolve(this.ufs) || resolve(funcInstance.ufs) || false
const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
let code = resolve(funcInstance.code)
const inputs = {
provider: this.provider,
role: this.role,
functionName: funcInstance.functionName,
functionDescription: funcInstance.functionDescription,
memorySize: resolve(funcInstance.memory) || resolve(this.memory),
timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
runtime,
handler: resolve(funcInstance.handler),
environment: {
...resolve(this.environment),
...resolve(funcInstance.environment)
},
async construct(inputs, context) {
await super.construct(inputs, context)
this.buildCmd = inputs.buildCmd
this.env = inputs.env
this.projectDir = resolve(inputs.projectDir)
this.assets = resolve(inputs.assets) || resolve(inputs.projectDir)
// TODO BRN: Move this to a validate step (maybe on a per property basis that validates when set)
if (!path.isAbsolute(this.projectDir)) {
throw new Error('projectDir must be an absolute path. Construct local paths using ${path}.')
}
this.envFileLocation = path.resolve(this.projectDir, resolve(inputs.envFileLocation))
this.assets = path.resolve(this.projectDir, resolve(inputs.assets))
}
(accum, value, key) => {
value = resolve(value)
if (isSerializable(value)) {
if (isSymbol(key)) {
const symbolString = getSymbolString(context, key)
if (symbolString) {
if (isSerializableReferenceable(value)) {
return set(['symbols', symbolString], toReference(context, value), accum)
}
return set(['symbols', symbolString], serializeValue(context, value), accum)
}
// context.log(`unhandled symbol detected ${toString(key)}`)
} else {
if (isSerializableReferenceable(value)) {
return set(['props', key], toReference(context, value), accum)
}
return set(['props', key], serializeValue(context, value), accum)
}
async defineFunction(functionInstance, context) {
const funcInstance = resolve(functionInstance)
// need to resolve these two variables now to convert values
const ufs = resolve(this.ufs) || resolve(funcInstance.ufs) || false
const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
let code = resolve(funcInstance.code)
const inputs = {
provider: this.provider,
role: this.role,
functionName: funcInstance.functionName,
functionDescription: funcInstance.functionDescription,
memorySize: resolve(funcInstance.memory) || resolve(this.memory),
timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
runtime,
handler: resolve(funcInstance.handler),
environment: {
...resolve(this.environment),
...resolve(funcInstance.environment)
},
code,
tags: {
...resolve(this.tags),
...resolve(funcInstance.tags)
}
}
if (ufs) {
code = [code, getShimFile(runtime)]
inputs.code = code
const concatSubscriptionAttributes = (inputs, state = {}) =>
concat(
// inputs subscriptionAttributes as array
map((key) => ({ [key]: inputs[key] }), keys(inputs)),
// state subscriptionAttributes as array with removed items
reduce(
(attributes, key) => {
if (!contains(key, keys(inputs))) {
// return empty object to "unset" removed value
return concat(attributes, [{ [key]: {} }])
}
return attributes
},
[],
keys(state)
)
)
const concatInputsAndState = (inputs, state = []) => {
const attributeKeys = map((item) => head(keys(item)), inputs)
return filter((item) => isNil(find(equals(item))(state)))(
concat(
inputs,
reduce(
(attributes, attribute) => {
const key = head(keys(attribute))
if (!contains(key, attributeKeys)) {
// return empty string to "unset" removed value
return concat(attributes, [{ [key]: '' }])
}
return attributes
},
[],
state
)
)