Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@almamedia-open-source/cdk-openapix

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@almamedia-open-source/cdk-openapix

![experimental](https://img.shields.io/badge/stability-experimental-yellow "Stability: Experimental")

  • 0.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

CDK OpenApiX

experimental

🚧 Work-in-Progress

🚨 Do not use this: Things may break at any given time & this project may be destroyed at any given time!










npm i -D @almamedia-open-source/cdk-openapix
const fn = new lambda.Function(this, "fn", {
  handler: "index.handler",
  runtime: lambda.Runtime.NODEJS_14_X,
  code: lambda.Code.fromInline('export function handler() { return { statusCode: 200, body: JSON.stringify("hello")} }'),
});

const pkName = 'item';

const table = new dynamodb.Table(this, 'table', {
  partitionKey: {
    type: dynamodb.AttributeType.STRING,
    name: pkName,
  }
});

const role = new iam.Role(this, "role", {
  assumedBy: new iam.ServicePrincipal('apigateway.amazonaws.com'),
});

table.grantReadData(role);

const apiDefinition = new OpenApiXDefinition(this, {
  upload: false, // by default add as inline Body, set to true to use as BodyS3Location
  source: './schema.yaml',
  integrations: {

    // Mock Integration
    '/mock': { 'GET': new OpenApiXMock(this) },

    // AWS Lambda Proxy integration
    '/message': { 'GET': new OpenApiXLambda(this, fn) },

    // HTTP Proxy integration
    '/ext': { 'GET': new OpenApiXHttp(this, "https://example.com") },

    // Direct integration to AWS Service
    '/item': { 'GET': new OpenApiXService(this, {
          service: 'dynamodb',
          action: 'GetItem',
          options: {
            credentialsRole: role,
            requestTemplates: {
              'application/json': JSON.stringify({
                "TableName": table.tableName,
                "Key": {
                  [pkName]: {
                    "S": "$input.params('item')"
                  }
                }
              }),
            },
          },
      }),
    },

  },

  injectPaths: { "info.title": "FancyPantsAPI" },
  rejectPaths: ['info.version'],

  // TODO add validators...
})


new apigateway.SpecRestApi(this, 'api', {
  apiDefinition,
});

// Also supports new OpenApiX()

Keywords

FAQs

Package last updated on 18 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc