Skip to content

Commit

Permalink
Merge pull request #489 from aws-amplify/merge-test
Browse files Browse the repository at this point in the history
Migrate API Category from CLI into this Repo
  • Loading branch information
alharris-at authored Jun 3, 2022
2 parents 390bfd0 + 506bc45 commit b0a4447
Show file tree
Hide file tree
Showing 175 changed files with 19,453 additions and 9 deletions.
7 changes: 7 additions & 0 deletions packages/amplify-category-api/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/__mocks__/**
**/__tests__/**
./src
tsconfig.json
tsconfig.tsbuildinfo
!resources/awscloudformation/overrides-resource/AppSync/tsconfig.json
!resources/awscloudformation/overrides-resource/APIGW/tsconfig.json
2,261 changes: 2,261 additions & 0 deletions packages/amplify-category-api/CHANGELOG.md

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions packages/amplify-category-api/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Amplify CLI API Plugin

## Commands Summary

The following table lists the current set of commands supported by the Amplify API Category Plugin.

| Command | Description |
| --- | --- |
| amplify api add | Takes you through steps in the CLI to add an API resource to your backend. |
| amplify api add-graphql-datasource | Takes you through the steps in the CLI to import an already existing Aurora Serverless data source to an existing GraphQL API resource.
| amplify api update | Takes you through steps in the CLI to update an API resource. |
| amplify api gql-compile | Compiles your GraphQL schema and generates a corresponding cloudformation template. |
| amplify api push | Provisions only API cloud resources with the latest local developments. |
| amplify api remove | Removes an API resource from your local backend. The resource is removed from the cloud on the next push command. |
21 changes: 21 additions & 0 deletions packages/amplify-category-api/amplify-plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "api",
"type": "category",
"commands": [
"add-graphql-datasource",
"add",
"console",
"gql-compile",
"migrate",
"override",
"push",
"rebuild",
"remove",
"update",
"help"
],
"commandAliases": {
"configure": "update"
},
"eventHandlers": []
}
135 changes: 135 additions & 0 deletions packages/amplify-category-api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"name": "@aws-amplify/amplify-category-api",
"version": "2.2.0",
"description": "amplify-cli api plugin",
"repository": {
"type": "git",
"url": "https://github.com/aws-amplify/amplify-category-api.git",
"directory": "packages/amplify-category-api"
},
"author": "Amazon Web Services",
"license": "Apache-2.0",
"main": "lib/index.js",
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"clean": "rimraf lib tsconfig.tsbuildinfo node_modules",
"test": "jest",
"generateSchemas": "ts-node ./scripts/generateApiSchemas.ts"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@aws-amplify/graphql-auth-transformer": "0.9.2",
"@aws-amplify/graphql-default-value-transformer": "0.5.24",
"@aws-amplify/graphql-function-transformer": "0.7.18",
"@aws-amplify/graphql-http-transformer": "0.8.18",
"@aws-amplify/graphql-index-transformer": "0.11.9",
"@aws-amplify/graphql-maps-to-transformer": "1.1.16",
"@aws-amplify/graphql-model-transformer": "0.14.2",
"@aws-amplify/graphql-predictions-transformer": "0.6.18",
"@aws-amplify/graphql-relational-transformer": "0.9.2",
"@aws-amplify/graphql-searchable-transformer": "0.14.2",
"@aws-amplify/graphql-transformer-core": "0.17.2",
"@aws-amplify/graphql-transformer-interfaces": "1.14.2",
"@aws-amplify/graphql-transformer-migrator": "1.2.38",
"@aws-cdk/assets": "~1.124.0",
"@aws-cdk/aws-apigateway": "~1.124.0",
"@aws-cdk/aws-apigatewayv2": "~1.124.0",
"@aws-cdk/aws-applicationautoscaling": "~1.124.0",
"@aws-cdk/aws-autoscaling": "~1.124.0",
"@aws-cdk/aws-autoscaling-common": "~1.124.0",
"@aws-cdk/aws-autoscaling-hooktargets": "~1.124.0",
"@aws-cdk/aws-certificatemanager": "~1.124.0",
"@aws-cdk/aws-cloudformation": "~1.124.0",
"@aws-cdk/aws-cloudfront": "~1.124.0",
"@aws-cdk/aws-cloudwatch": "~1.124.0",
"@aws-cdk/aws-codebuild": "~1.124.0",
"@aws-cdk/aws-codeguruprofiler": "~1.124.0",
"@aws-cdk/aws-codepipeline": "~1.124.0",
"@aws-cdk/aws-codepipeline-actions": "~1.124.0",
"@aws-cdk/aws-cognito": "~1.124.0",
"@aws-cdk/aws-ec2": "~1.124.0",
"@aws-cdk/aws-ecr": "~1.124.0",
"@aws-cdk/aws-ecr-assets": "~1.124.0",
"@aws-cdk/aws-ecs": "~1.124.0",
"@aws-cdk/aws-efs": "~1.124.0",
"@aws-cdk/aws-elasticloadbalancing": "~1.124.0",
"@aws-cdk/aws-elasticloadbalancingv2": "~1.124.0",
"@aws-cdk/aws-events": "~1.124.0",
"@aws-cdk/aws-iam": "~1.124.0",
"@aws-cdk/aws-kms": "~1.124.0",
"@aws-cdk/aws-lambda": "~1.124.0",
"@aws-cdk/aws-logs": "~1.124.0",
"@aws-cdk/aws-route53": "~1.124.0",
"@aws-cdk/aws-route53-targets": "~1.124.0",
"@aws-cdk/aws-s3": "~1.124.0",
"@aws-cdk/aws-s3-assets": "~1.124.0",
"@aws-cdk/aws-sam": "~1.124.0",
"@aws-cdk/aws-secretsmanager": "~1.124.0",
"@aws-cdk/aws-servicediscovery": "~1.124.0",
"@aws-cdk/aws-sns": "~1.124.0",
"@aws-cdk/aws-sns-subscriptions": "~1.124.0",
"@aws-cdk/aws-sqs": "~1.124.0",
"@aws-cdk/aws-ssm": "~1.124.0",
"@aws-cdk/cloud-assembly-schema": "~1.124.0",
"@aws-cdk/core": "~1.124.0",
"@aws-cdk/custom-resources": "~1.124.0",
"@aws-cdk/cx-api": "~1.124.0",
"@aws-cdk/region-info": "~1.124.0",
"@graphql-tools/merge": "^6.0.18",
"@octokit/rest": "^18.0.9",
"amplify-cli-core": "^2.9.0",
"amplify-headless-interface": "^1.15.0",
"amplify-prompts": "^2.2.0",
"amplify-provider-awscloudformation": "^6.3.0",
"amplify-util-headless-input": "^1.9.5",
"chalk": "^4.1.1",
"cloudform": "^4.2.0",
"cloudform-types": "^4.2.0",
"constructs": "^3.3.125",
"fs-extra": "^8.1.0",
"graphql": "^14.5.8",
"graphql-auth-transformer": "7.2.34",
"graphql-connection-transformer": "5.2.34",
"graphql-dynamodb-transformer": "7.2.34",
"graphql-elasticsearch-transformer": "5.2.34",
"graphql-function-transformer": "3.3.25",
"graphql-http-transformer": "5.2.34",
"graphql-key-transformer": "3.2.34",
"graphql-predictions-transformer": "3.2.34",
"graphql-relational-schema-transformer": "2.21.7",
"graphql-transformer-common": "4.23.1",
"graphql-transformer-core": "7.5.2",
"graphql-versioned-transformer": "5.2.34",
"import-from": "^3.0.0",
"import-global": "^0.1.0",
"inquirer": "^7.3.3",
"js-yaml": "^4.0.0",
"lodash": "^4.17.21",
"ora": "^4.0.3",
"rimraf": "^3.0.0",
"uuid": "^8.3.2"
},
"devDependencies": {
"@aws-cdk/assertions": "~1.124.0",
"@types/js-yaml": "^4.0.0"
},
"jest": {
"testURL": "http://localhost",
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "((\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"collectCoverage": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "An auto-generated nested stack.",
"Metadata": {},
"Parameters": {
"AppSyncApiId": {
"Type": "String",
"Description": "The id of the AppSync API associated with this project."
},
"AppSyncApiName": {
"Type": "String",
"Description": "The name of the AppSync API",
"Default": "AppSyncSimpleTransform"
},
"env": {
"Type": "String",
"Description": "The environment name. e.g. Dev, Test, or Production",
"Default": "NONE"
},
"S3DeploymentBucket": {
"Type": "String",
"Description": "The S3 bucket containing all deployment assets for the project."
},
"S3DeploymentRootKey": {
"Type": "String",
"Description": "An S3 key relative to the S3DeploymentBucket that points to the root\nof the deployment directory."
}
},
"Resources": {
"EmptyResource": {
"Type": "Custom::EmptyResource",
"Condition": "AlwaysFalse"
}
},
"Conditions": {
"HasEnvironmentParameter": {
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "env"
},
"NONE"
]
}
]
},
"AlwaysFalse": {
"Fn::Equals": ["true", "false"]
}
},
"Outputs": {
"EmptyOutput": {
"Description": "An empty output. You may delete this if you have at least one resource above.",
"Value": ""
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: "3.8"
services:
express:
build:
context: ./express
dockerfile: Dockerfile
ports:
- "8080:8080"
networks:
- public
- private
python:
build:
context: ./python
dockerfile: Dockerfile
networks:
- public
- private
ports:
- "5000:5000"
networks:
public:
private:
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM public.ecr.aws/bitnami/node:14-prod-debian-10

ENV PORT=8080
EXPOSE 8080

WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install
COPY . .

CMD [ "node", "index.js" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient();

const TableName = process.env.STORAGE_POSTS_NAME;

const addPostToDDB = async ({ id, title, author, description, topic }) => {

var params = {
Item: {
id: parseInt(id, 10),
title: title,
author: author,
description: description,
topic: topic
},
TableName: TableName
}
try {
const data = await docClient.put(params).promise()
return params.Item;
} catch (err) {
console.log('Error: ' + err);
return err
}
}

const scanPostsFromDDB = async () => {
var params = {
TableName: TableName,
}

try {
const data = await docClient.scan(params).promise();
return data.Items;
} catch (err) {
console.log('Error: ' + err);
return err;
}
}

const getPostFromDDB = async (id) => {
const key = parseInt(id, 10);
var params = {
TableName: TableName,
Key: { id: key },
}
try {
const data = await docClient.get(params).promise()
return data.Item;
} catch (err) {
console.log('Error: ' + err);
return err
}
}

module.exports = {
addPostToDDB,
scanPostsFromDDB,
getPostFromDDB
};
Loading

0 comments on commit b0a4447

Please sign in to comment.