How to use the @serverless/utils.all function in @serverless/utils

To help you get started, we’ve selected a few @serverless/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github serverless / serverless-websockets-plugin / src / index.js View on Github external
async createRoutes() {
    const integrationsPromises = map(async (fn) => {
      const integrationId = await this.createIntegration(fn.arn)
      await this.addPermission(fn.arn)
      const routesPromises = map((route) => this.createRoute(integrationId, route), fn.routes)
      return all(routesPromises)
    }, this.functions)

    return all(integrationsPromises)
  }
github serverless / serverless-websockets-plugin / src / index.js View on Github external
async clearRoutes() {
    const res = await this.provider.request('ApiGatewayV2', 'getRoutes', { ApiId: this.apiId })
    return all(
      map(
        (route) =>
          this.provider.request('ApiGatewayV2', 'deleteRoute', {
            ApiId: this.apiId,
            RouteId: route.RouteId
          }),
        res.Items
      )
    )
  }
github serverless / serverless-websockets-plugin / src / index.js View on Github external
async createAuthorizers() {
    const authorizerPromises = map(async (authorizerName) => {
        const authorizer = this.authorizers[authorizerName]
        await this.addPermission(authorizer.arn)
        return this.createAuthorizer(authorizer)
    }, keys(this.authorizers))
    await all(authorizerPromises)
  }
github serverless / components / src / types / AwsIamPolicy / index.js View on Github external
const deletePolicy = async (IAM, name, arn, context) => {
  const { PolicyGroups, PolicyRoles, PolicyUsers } = await IAM.listEntitiesForPolicy({
    PolicyArn: arn
  }).promise()

  await all(
    PolicyGroups.map((group) => IAM.detachGroupPolicy({ GroupName: group })),
    PolicyRoles.map((role) => IAM.detachRolePolicy({ RoleName: role })),
    PolicyUsers.map((user) => IAM.detachUserPolicy({ UserName: user }))
  )

  await IAM.deletePolicy({
    PolicyArn: arn
  }).promise()
  context.log(`Policy '${name}' deleted.`)

  return null
}
github serverless / components / src / utils / dag / execGraph.js View on Github external
const execNodeIds = async (iteratee, nodeIds, graph, context) =>
  all(
    reduce(
      (accum, nodeId) => {
        const node = graph.node(nodeId)
        if (!node) {
          throw new Error(`could not find node for nodeId:${nodeId}`)
        }
        graph.removeNode(nodeId)
        return append(execNode(iteratee, node, context), accum)
      },
      [],
      nodeIds
    )
  )
github serverless / serverless-websockets-plugin / src / index.js View on Github external
async clearIntegrations() {
    const res = await this.provider.request('ApiGatewayV2', 'getIntegrations', { ApiId: this.apiId })
    return all(
      map(
        (integration) =>
          this.provider.request('ApiGatewayV2', 'deleteIntegration', {
            ApiId: this.apiId,
            IntegrationId: integration.IntegrationId
          }),
        res.Items
      )
    )
  }
github serverless / serverless-websockets-plugin / src / index.js View on Github external
const integrationsPromises = map(async (fn) => {
      const integrationId = await this.createIntegration(fn.arn)
      await this.addPermission(fn.arn)
      const routesPromises = map((route) => this.createRoute(integrationId, route), fn.routes)
      return all(routesPromises)
    }, this.functions)
github serverless / components / src / types / Service / index.js View on Github external
async construct(inputs, context) {
      await super.construct(inputs, context)
      this.functions = await all(
        mapObjIndexed(
          async (func, alias) =>
            context.construct(Fn, {
              ...func,
              functionName: func.functionName || alias
            }),
          resolve(this.functions)
        )
      )
    }
github serverless / serverless-websockets-plugin / src / index.js View on Github external
async clearAuthorizers() {
    const res = await this.provider.request('ApiGatewayV2', 'getAuthorizers', { ApiId: this.apiId })
    return all(
      map(
        (authorizer) =>
          this.provider.request('ApiGatewayV2', 'deleteAuthorizer', {
            ApiId: this.apiId,
            AuthorizerId: authorizer.AuthorizerId
          }),
        res.Items
      )
    )
  }